Yorkie

ExamplesRich Text Editor iOS

Rich Text Editor iOS

This is an example of real-time collaborative Rich Text Editor using Yorkie iOS SDK.

    RichTextEditorApp.swift
    1/*
    2 * Copyright 2025 The Yorkie Authors. All rights reserved.
    3 *
    4 * Licensed under the Apache License, Version 2.0 (the "License");
    5 * you may not use this file except in compliance with the License.
    6 * You may obtain a copy of the License at
    7 *
    8 * http://www.apache.org/licenses/LICENSE-2.0
    9 *
    10 * Unless required by applicable law or agreed to in writing, software
    11 * distributed under the License is distributed on an "AS IS" BASIS,
    12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13 * See the License for the specific language governing permissions and
    14 * limitations under the License.
    15 */
    16
    17import SwiftUI
    18
    19@main
    20struct RichTextEditorApp: App {
    21 @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    22 @Environment(\.scenePhase) var scenePhase
    23 @State var key = Constant.documentKey
    24
    25 var body: some Scene {
    26 WindowGroup {
    27 NavigationView {
    28 VStack {
    29 Text("Input document key or use the default")
    30 TextField(text: self.$key) {
    31 Text("Input documentKey")
    32 }
    33
    34 NavigationLink(destination: ContentView()) {
    35 Text("Go")
    36 }
    37 }
    38 .padding()
    39 }
    40 .navigationViewStyle(.stack)
    41 }.onChange(of: self.scenePhase) { newPhase in
    42 Log.log("[ChangePhase] -> \(newPhase)", level: .debug)
    43 }
    44 .onChange(of: self.key) { newValue in
    45 Constant.documentKey = newValue
    46 }
    47 }
    48}
    49
    50final class AppDelegate: NSObject, UIApplicationDelegate {
    51 func application(
    52 _: UIApplication,
    53 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
    54 ) -> Bool {
    55 return true
    56 }
    57}
    GitHub
    Your browser does not support the video tag.