Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to $set() value of CodeField and have that change reflected in Codemirror editor #9

Open
HelgeSverre opened this issue Apr 20, 2023 · 2 comments

Comments

@HelgeSverre
Copy link

Calling $set() on the CodeField, has no effect, it will set the value (so it will be saved to the DB), but the codemirror editor will not pickup on the change.

Unsure how to resolve.

Can be reproduced by the following snippet:

 CodeField::make('html')
    ->label('Custom HTML')
    ->reactive()
    ->columnSpanFull()
    ->withLineNumbers()
    ->htmlField()
    ->minHeight(400)
    ->disableAutocompletion()
    ->hintAction(function (Closure $set) {
        return Action::make('make_html_go_brrrr')
            ->icon('heroicon-o-sparkles')
            ->label('Go brrrr')
            ->action(function () use ($set) {
                $set("html", "brrrrrrrr");
            });
    }),

The expected result is for the codemirror editor to now contain "brrrrrrrr", however it is blank "or has whatever value you wrote in before clicking the hintAction button)

@ricardcreagia
Copy link
Collaborator

We currently have a way to set the field as display mode using ->displayMode().

Do you need to $set() and write code at the same time? Haven't figured out a way to make the field work bidirectional without producing an infinite loop.

@HelgeSverre
Copy link
Author

I am trying to set and allow it to be editable at the same time, using this ai feature to generate html or whatever as a starting point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants