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

Make is possible to replace text at range #47

Open
danielsaidi opened this issue May 18, 2023 · 2 comments
Open

Make is possible to replace text at range #47

danielsaidi opened this issue May 18, 2023 · 2 comments
Labels
feature New feature or request

Comments

@danielsaidi
Copy link
Owner

We can currently use the context to select a range, but not replace the currently selected text.

This should be possible when replacing text.

Replace the pasteText function with an insertText(at: position) (non-replacing) and insertText(at: range) (replacing).

@danielsaidi danielsaidi added the feature New feature or request label May 18, 2023
@savanteer
Copy link

Thank you again for your truly impressive library. What a gift!

It appears to already be possible (early Aug '23) to replace text at a specific offset:

context.pasteText("<some text>", at: <some offset>, moveCursorToPastedContent: T/F)

But yes, a range would definitely be more usable. However, the solution should support styled text (ie, NSAttributedString) as well. For example:

let attr = [NSAttributedString.Key.foregroundColor: UIColor.lightGray, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 24]
let text = NSMutableAttributedString(string: "<some text here>\n", attributes: attr)

<magic>.replaceText(in: context.selectedRange, with: text)

FWIW, pasteText() does not appear to accommodate styled text.

@danielsaidi
Copy link
Owner Author

Hi @savanteer

Thanks for your feedback! I hope to have time to work on this in a few weeks.

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

No branches or pull requests

2 participants