AztecEditor-iOS icon indicating copy to clipboard operation
AztecEditor-iOS copied to clipboard

New line / Line Break after added new image in the editor

Open ramdhasm opened this issue 4 years ago • 1 comments

Describe the bug Need to move the cursor to next line after i added image in the editor. Now, the cursor is right side of image. Tried to add " \n and br tag " like below

func insertImage(_ image: UIImage) {
        let attachment = richTextView.replaceWithImage(at: richTextView.selectedRange, sourceURL: fileURL!, placeHolderImage: image)
        attachment.size = .full
        attachment.alignment = ImageAttachment.Alignment.none
        if let attachmentRange = richTextView.textStorage.ranges(forAttachment: attachment).first {
            richTextView.setLink(fileURL!, inRange: attachmentRange)
        }
        
        richTextView.becomeFirstResponder()
//        richTextView.text = richTextView.text + "\n"
//        editorView.setHTML(editorView.getHTML()+"</p>\n<p>")
        
        let imageID = attachment.identifier
        let progress = Progress(parent: nil, userInfo: [MediaProgressKey.mediaID: imageID])
        progress.totalUnitCount = 100
    }
//        editorView.setHTML(editorView.getHTML()+"</p>\n<p>")
//        richTextView.text = richTextView.text + "\n"

Nothing worked.

To Reproduce Steps to reproduce the behavior:

  1. Type some text
  2. Click + button to open image picker, choose image
  3. Image added in editor but the cursor in right side of image
  4. Need to press return button in the keyboard to make the cursor to come next line. But, how i can make it programmatically to move next line

Expected behavior Need to press return button in the keyboard to make the cursor to come next line. But, how i can make it programmatically to move next line

Smartphone (please complete the following information):

  • Device: iOS

ramdhasm avatar Apr 05 '20 19:04 ramdhasm

richTextEditorView.replace(richTextEditorView.selectedRange, withHTML: "<br><br>")

This works for me.

csjryt avatar Aug 15 '21 06:08 csjryt