Skip to content

Commit d495944

Browse files
committed
feat: iOS apps append text at cursor
1 parent 4c1dfc8 commit d495944

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ios/Sources/GutenbergKit/Sources/EditorViewController.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,14 @@ public final class EditorViewController: UIViewController, GutenbergEditorContro
297297
evaluate("editor.setMediaUploadAttachment(\(media));")
298298
}
299299

300+
/// Appends text at the current cursor position in the editor.
301+
///
302+
/// - parameter text: The text to append at the cursor position.
303+
public func appendTextAtCursor(_ text: String) {
304+
let escapedText = text.addingPercentEncoding(withAllowedCharacters: .alphanumerics) ?? text
305+
evaluate("editor.appendTextAtCursor(decodeURIComponent('\(escapedText)'));")
306+
}
307+
300308
// MARK: - GutenbergEditorControllerDelegate
301309

302310
fileprivate func controller(_ controller: GutenbergEditorController, didReceiveMessage message: EditorJSMessage) {

0 commit comments

Comments
 (0)