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

There is a situation where the page API cannot retrieve the editor type. #5117

Closed
toras9000 opened this issue Jul 12, 2024 · 2 comments
Closed

Comments

@toras9000
Copy link

Describe the Bug

In the newly created page, the editor property is empty in the PAGES-LIST or PAGES-READ API response results.
This seems to occur when a new page is saved with the configured default editor.
When creating or editing a page, if you switch the editor type and then save the page, the type will be available in the editor property of the API response thereafter.

Steps to Reproduce

  1. Create a new page in any book.
    • At this time, save the file without switching the editor type.
  2. Obtain information via the PAGES-LIST or PAGES-READ API.
    • The editor property of the API response data is empty.

Expected Behaviour

The editor property of the API response gets the appropriate value.

Screenshots or Additional Context

No response

Browser Details

No response

Exact BookStack Version

v24.05.2

@ssddanbrown
Copy link
Member

Thanks for raising @toras9000, I can confirm this.
I've assigned to the next feature release rather than fix this in a sooner patch because we'll want to apply some database changes to address this fully which is something I'd rather leave to non-minor versions.

Dev notes

System currently won't set editor value if aligned with system default.
Probably worth updating the change logic to actually update, even if without permissions but existing value is empty as a backup option:

if ($newEditor !== $currentEditor && userCan('editor-change')) {
$page->editor = $newEditor;
}

But ultimately the value needs to be set on initial page creation/store.

Should also update the existing pages without editor values, for which I think we can follow the original logic we used for the field on column creation:

// Populate the new 'editor' column
// We set it to 'markdown' for pages currently with markdown content
DB::table('pages')->where('markdown', '!=', '')->update(['editor' => 'markdown']);
// We set it to 'wysiwyg' where we have HTML but no markdown
DB::table('pages')->where('markdown', '=', '')
->where('html', '!=', '')
->update(['editor' => 'wysiwyg']);

ssddanbrown added a commit that referenced this issue Sep 29, 2024
- Migration for setting on existing pages
- Added test to cover simple new page scenario

For #5117
@ssddanbrown
Copy link
Member

This has now been updated in 89f84c9 to always set an editor type, and this will be part of the next feature release.

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

No branches or pull requests

2 participants