Skip to content

Conversation

@max-nextcloud
Copy link
Collaborator

@max-nextcloud max-nextcloud commented Jul 29, 2025

  • chore(extract): TranslateButton from MenuBar
  • chore(move): handleEditorWidthChange into SessionList
  • chore(npm): prettier:change to format only changed files
  • fix(width): load initial state in editor
  • fix(width): remember full width on remount
  • fix(width): use nextcloud event bus to sync width
  • fix(width): move toggle into remaining actions menu

@max-nextcloud max-nextcloud requested a review from mejo- as a code owner July 29, 2025 12:32
@codecov
Copy link

codecov bot commented Jul 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.92%. Comparing base (b874cae) to head (2050ce8).
⚠️ Report is 20 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #7514       +/-   ##
===========================================
+ Coverage   46.65%   59.92%   +13.27%     
===========================================
  Files         498      500        +2     
  Lines       42153    38218     -3935     
  Branches     1160     1140       -20     
===========================================
+ Hits        19665    22904     +3239     
+ Misses      22370    15206     -7164     
+ Partials      118      108       -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@max-nextcloud max-nextcloud force-pushed the fix/move-wide-page-toggle branch 2 times, most recently from a913266 to bcb708b Compare July 30, 2025 07:14
Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this. I found some minor issues and have some questions 😆

@max-nextcloud
Copy link
Collaborator Author

max-nextcloud commented Aug 3, 2025

The only thing that's missing from also fixing #6703 would be hiding the toggle in collectives as collectives has its own toggle. I'm unsure how best to achieve this though.

  • We could hide it everywhere where createEditor is used - but that seems too generic.
  • Collectives could specify a parameter to createEditor.
  • Collectives could provide some data that we inject in the Editor that hides the toggle.

Alternatively we could make the toggle work on the collectives per page setting - but I wonder if that would be more confusing or less.

update: I found a different way (f8ee194):
Text now detects the width has already been set and does not render the width toggle anymore.

Next steps:
* split it to a separate component.
* move it into the remaining actions menu item.

Signed-off-by: Max <[email protected]>
This way the editor width is adjusted before the session list loads.

Signed-off-by: Max <[email protected]>
After closing and reopening the editor
the full width value was read from initial state again.

Use a singleton instead so the toggled state is persisted.

Signed-off-by: Max <[email protected]>
If multiple editors are open (i.e. folder description and viewer)
set the full width value on both of them using the event bus.

Signed-off-by: Max <[email protected]>
The component is used inside NcActions now.

Signed-off-by: Max <[email protected]>
@max-nextcloud max-nextcloud force-pushed the fix/move-wide-page-toggle branch from becbd1d to 9804c10 Compare August 12, 2025 08:09
const setByText = document.documentElement.style.getPropertyValue(
'--text-editor-max-width',
)
return alreadySet && alreadySet !== setByText
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fear I don't fully understand the logic here. Both read the value of the css variable --text-editor-max-width, the first from the <body> element, the second from the root element (<html>). So Text attaches the variable to the root <html> element and Collectives attaches it to the <body> element and that's how you distinguish them?

In my tests with latest master branch of server, the latter is always empty, even if I open a text editor from the Files app. In other words I never see the full width toggle at the moment.

In general, this feels a bit brittle to me as it will make the fullWidth toggle disappear as soon as we change something with how --text-editor-max-width is set.

Maybe it's really better to be more explicit and make this configurable via the editorApi at editor.js?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked the code and it seems to me that actually both Text and Collectives set --text-editor-max-width on the root element: see https://github.com/nextcloud/collectives/blob/aeffe87608250a50d0eb99b526362616fa2e0eb2/src/css/editor.scss#L7 and

--text-editor-max-width: 80ch;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I don't understand why you use getComputedProperties(<element>) first and <element>.style second. Is this intended?

Copy link
Collaborator Author

@max-nextcloud max-nextcloud Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I am trying to do here is this:

  1. Read the effective value of --text-editor-max-width for the document body. I'm using getComputedStyle so it does not matter where exactly the style is set - wether on the body element or :root or in some other way.
  2. Check if text has set a value already - for example because it was opened before. This value would always be set on document.documentElement.style (as implemented below).
  3. If 1. and 2. both have a value set - check if it's the same to determine if 1 is only set because of 2.

Now let me figure out why this is not working as intended.

Copy link
Collaborator Author

@max-nextcloud max-nextcloud Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay... I see what's happening here. Text also set's the width on :root - twice in fact. So 1 returns a value even when 2 has not been set yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text set the --text-editor-max-width in css. I removed that as it will be set either externally or by useEditorWidth now.

@max-nextcloud max-nextcloud force-pushed the fix/move-wide-page-toggle branch from d9b7cbe to b76ac59 Compare August 12, 2025 12:32
@max-nextcloud max-nextcloud requested a review from mejo- August 12, 2025 12:33
@max-nextcloud max-nextcloud force-pushed the fix/move-wide-page-toggle branch from b76ac59 to 8f1c46b Compare August 12, 2025 18:37
Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed this PR is good to go from my side with two minor comments. One I put in the code, the other would be that a Cypress test would be great to protect against regresssions.

The collectives app has its own mechanism for setting the desired editor width.
Detect the custom width being set and do not render the width toggle.

Signed-off-by: Max <[email protected]>
This way it is easier to test and all the translation logic is in one place.

Signed-off-by: Max <[email protected]>
@max-nextcloud max-nextcloud force-pushed the fix/move-wide-page-toggle branch from 8f1c46b to 2050ce8 Compare August 13, 2025 20:46
@max-nextcloud max-nextcloud merged commit c36e12a into main Aug 13, 2025
66 checks passed
@max-nextcloud max-nextcloud deleted the fix/move-wide-page-toggle branch August 13, 2025 21:21
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

Successfully merging this pull request may close these issues.

toggle for editor line length per user is not persistant Line length toggle follow ups

3 participants