Skip to content

Adds an option to disable multiple indentations in lists #364

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

YoX89
Copy link
Contributor

@YoX89 YoX89 commented Apr 11, 2025

No description provided.

@rajdeep
Copy link
Owner

rajdeep commented Apr 12, 2025

@YoX89, can you please explain what your intension is with this PR as I am not sure if I understand it correctly looking at the snapshots in the PR. Both the snapshot 1 and 2 are same. Do you intend to create a feature that allows you to disable indenting if more than 1 list item is selected or if it is being indented by more than 1 level with respect to parent? Latter one is already implemented and expected to work.

@YoX89
Copy link
Contributor Author

YoX89 commented Apr 12, 2025

My PR is to limit indentation so it's not possible to indent any list more than the first level. So if your indentation formatting is 25 it will only ever be indented 25 as a maximum. Not 50, 75 etc.

Only one level of lists.

Is that already possible?

@rajdeep
Copy link
Owner

rajdeep commented Apr 12, 2025

@YoX89, that's correct. This is the default behaviour. See the demo below that I just verified on iOS 18 simulator where I am pressing tab key multiple times at each level:

Simulator Screen Recording - iPhone 16 Pro - 2025-04-12 at 16 26 45

To ensure that you are getting the correct behaviour, please use ListTextProcessor.handleKeyWithModifiers and pass values accordingly, e.g. key: tab for indentation.

@rajdeep
Copy link
Owner

rajdeep commented Apr 12, 2025

@YoX89, for reference, this is the code that prevents indentation beyond 1 level.

@YoX89
Copy link
Contributor Author

YoX89 commented Apr 12, 2025

Sorry I wasn't being clear! I don't mean only one indentation compared to its parent. I don't want any indentation at all.

In your example above there are 4 levels. Each one level indented compared to its parent. I don't want any levels except for the first one.

In my snapshot it's intentionally the same picture. I have a list and when I tap tab it doesn't indent further because the highest total level allowed is one.

@rajdeep
Copy link
Owner

rajdeep commented Apr 12, 2025

@YoX89, got it. thanks for clarifying. I think, this is something that can be handled even without any change in Proton. You can use EditorViewDelegate didChangeSelection function. Depending on the UI you have to change the indentation, you can add logic in didChangeSelection and check for FirstLineHeadIndent for .paragraphStyle attribute. If it is the indentation that you have, you can disable indentation or handle in any other manner. If the selection length is greater than 0, you will also get .listItem attribute that you can inspect. This is called every time the selection changes either as a result of text being typed or when user taps to change the selection. Hope that helps.

Also note, creating list at first level is done using ListCommand and additional indentations are handled by ListTextProcessor. If you are only using ListCommand, it's execute function will add/remove list level at first level only. If you have ListTextProcessor registered, probably the only change you need is to remove that.

@YoX89
Copy link
Contributor Author

YoX89 commented Apr 12, 2025

Thank you! I'll have a look on Monday if I can solve it without any changes to Proton.

@YoX89
Copy link
Contributor Author

YoX89 commented Apr 14, 2025

Hi! Tried it out a bit now. Without registering ListTextProcessor list markers don't work beyond the first one. But you were correct that it didn't indent further when tabbing.
Simulator Screen Recording - iPhone 16 Pro - 2025-04-14 at 07 58 12

Also looked at didChangeSelection, it doesn't always get triggered when you press tab for example. So I'm not sure I can make it work using only that override. Here's an example of where I tab to indent the second line but didChangeSelection is not called.
Simulator Screen Recording - iPhone 16 Pro - 2025-04-14 at 08 33 42

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.

2 participants