From d4bef39779bc5f997cc8c5e0074ea0573038433e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 28 May 2025 14:43:44 +0200 Subject: [PATCH] update editor --- src/Components/Input/TextAreaInput.tsx | 61 ++++++++++------- src/Components/Input/TextInput.cy.tsx | 66 ------------------- src/Components/Profile/Templates/TabsForm.tsx | 7 +- 3 files changed, 43 insertions(+), 91 deletions(-) delete mode 100644 src/Components/Input/TextInput.cy.tsx diff --git a/src/Components/Input/TextAreaInput.tsx b/src/Components/Input/TextAreaInput.tsx index a12615ec..726659b0 100644 --- a/src/Components/Input/TextAreaInput.tsx +++ b/src/Components/Input/TextAreaInput.tsx @@ -1,5 +1,8 @@ -import { useEffect, useRef, useState } from 'react' -import SimpleMDE from 'react-simplemde-editor' +import { useEffect, useMemo, useRef, useState } from 'react' +import { SimpleMdeReact } from 'react-simplemde-editor' + +import type SimpleMDE from 'easymde' +import type { InputHTMLAttributes } from 'react' interface TextAreaProps { labelTitle?: string @@ -42,25 +45,14 @@ export function TextAreaInput({ } } - console.log('required not enforced', required) - return ( -
- {labelTitle ? ( - - ) : null} - { + return { + status: false, + lineNumbers: false, + minHeight: '100px', + forceSync: true, + // inputStyle: 'textarea', + /* autoDownloadFontAwesome?: boolean; autofocus?: boolean; autosave?: AutoSaveOptions; @@ -72,7 +64,6 @@ export function TextAreaInput({ indentWithTabs?: boolean; initialValue?: string; insertTexts?: InsertTextOptions; - lineNumbers?: boolean; lineWrapping?: boolean; minHeight?: string; maxHeight?: string; @@ -121,8 +112,32 @@ export function TextAreaInput({ overlayMode?: OverlayModeOptions; direction?: 'ltr' | 'rtl'; + */ + } as SimpleMDE.Options + }, []) + + return ( +
+ {labelTitle ? ( + + ) : null} + } - */ + ref={ref} + id={dataField} + value={inputValue} + placeholder={placeholder ?? ''} + onChange={handleChange} + options={options} className={`${inputStyle ?? ''}`} />
diff --git a/src/Components/Input/TextInput.cy.tsx b/src/Components/Input/TextInput.cy.tsx deleted file mode 100644 index d0fc069a..00000000 --- a/src/Components/Input/TextInput.cy.tsx +++ /dev/null @@ -1,66 +0,0 @@ -/// -import { mount } from 'cypress/react' - -import { TextInput } from './TextInput' - -describe('', () => { - it('renders with default props', () => { - mount() - cy.get('input').should('have.attr', 'type', 'text') - cy.get('input').should('have.attr', 'placeholder', '') - cy.get('input').should('have.attr', 'required') - cy.get('input').should('have.class', 'input') - cy.get('input').should('have.class', 'input-bordered') - cy.get('input').should('have.class', 'tw:w-full') - }) - - it('renders with given labelTitle', () => { - mount() - cy.get('label').should('contain.text', 'Test Title') - }) - - it('renders with given type', () => { - mount() - cy.get('input').should('have.attr', 'type', 'email') - }) - - it('accepts user input', () => { - mount() - cy.get('input[name="test-input"]').type('Hello Test') - cy.get('input[name="test-input"]').should('have.value', 'Hello Test') - }) - - it('renders a label, if labelTitle is set', () => { - mount() - cy.contains('Test Label').should('exist') - }) - - it('handles default value correctly', () => { - mount() - cy.get('input[name="test-input"]').should('have.value', 'Default Value') - }) - - it('calls updateFormValue on change', () => { - const onChangeSpy = cy.spy().as('updateFormValueSpy') - mount() - cy.get('input[name="test-input"]').type('Test') - cy.get('@updateFormValueSpy').should('have.been.calledWith', 'Test') - }) - - it('accepts a specific input type', () => { - mount() - cy.get('input[name="test-input"]').should('have.attr', 'type', 'email') - }) - - it('respects the autocomplete attribute', () => { - mount() - cy.get('input[name="test-input"]').should('have.attr', 'autocomplete', 'off') - }) - - it('updates form value on change', () => { - const updateFormValue = cy.stub() - mount() - cy.get('input').type('Hello') - cy.wrap(updateFormValue).should('have.been.calledWith', 'Hello') - }) -}) diff --git a/src/Components/Profile/Templates/TabsForm.tsx b/src/Components/Profile/Templates/TabsForm.tsx index f9931b28..412af778 100644 --- a/src/Components/Profile/Templates/TabsForm.tsx +++ b/src/Components/Profile/Templates/TabsForm.tsx @@ -91,6 +91,7 @@ export const TabsForm = ({ )} @@ -99,10 +100,11 @@ export const TabsForm = ({ text: v, })) } - containerStyle='tw:grow' + // containerStyle='tw:grow' inputStyle={`tw:h-full ${!item.layer.itemType.show_start_end_input && 'tw:border-t-0 tw:rounded-tl-none'}`} /> @@ -112,7 +114,8 @@ export const TabsForm = ({ })) } inputStyle='' - containerStyle='tw:pt-4 tw:h-24 tw:flex-none' + containerStyle='tw:pt-4' + // containerStyle='tw:pt-4 tw:h-24 tw:flex-none' required={false} />