Compare commits
19 Commits
1ff250fa17
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a525c763e | |||
| a0dffdc715 | |||
| 4765d48021 | |||
| f888e28d15 | |||
| c934dbad84 | |||
| 4088db8ec0 | |||
| 255f171aa8 | |||
| 70870e1ec2 | |||
| f1a380d105 | |||
| 01ad237af3 | |||
| 7d49f7d5a4 | |||
| 87eb958869 | |||
| 4340fd3635 | |||
| ac2eac5fcd | |||
| a386802a55 | |||
| 1f94b9884c | |||
| 58a8d27315 | |||
| 7f4fc34dbf | |||
| 5af8038ec0 |
@@ -184,6 +184,7 @@
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
"zh-Hans",
|
||||
);
|
||||
mainGroup = CFD40B073003C283009C9F2A;
|
||||
minimizedProjectReferenceProxies = 1;
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
//
|
||||
// ClipEditViewController.swift
|
||||
// Note
|
||||
//
|
||||
// Created by Kimi Code CLI on 2026/7/15.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class ClipEditViewController: UIViewController {
|
||||
|
||||
private var textView: UITextView!
|
||||
private var floatingDoneButton: UIButton!
|
||||
private var floatingDoneButtonBottomConstraint: NSLayoutConstraint!
|
||||
private var clip: Clip
|
||||
|
||||
init(clip: Clip) {
|
||||
self.clip = clip
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
title = "编辑文案"
|
||||
navigationItem.largeTitleDisplayMode = .never
|
||||
view.backgroundColor = .systemGroupedBackground
|
||||
|
||||
setupNavigationBar()
|
||||
setupTextView()
|
||||
setupKeyboardObservers()
|
||||
}
|
||||
|
||||
deinit {
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
|
||||
private func setupKeyboardObservers() {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
|
||||
}
|
||||
|
||||
@objc private func keyboardWillShow(_ notification: Notification) {
|
||||
guard let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }
|
||||
let keyboardFrameInView = view.convert(keyboardFrame, from: nil)
|
||||
let intersection = keyboardFrameInView.intersection(view.bounds)
|
||||
let keyboardHeight = intersection.height
|
||||
|
||||
let duration = notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? TimeInterval ?? 0.25
|
||||
|
||||
UIView.animate(withDuration: duration, delay: 0, options: .beginFromCurrentState) {
|
||||
self.textView.contentInset.bottom = keyboardHeight
|
||||
self.textView.verticalScrollIndicatorInsets.bottom = keyboardHeight
|
||||
self.floatingDoneButtonBottomConstraint.constant = -(keyboardHeight + 8)
|
||||
self.floatingDoneButton.alpha = 1
|
||||
self.view.layoutIfNeeded()
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func keyboardWillHide(_ notification: Notification) {
|
||||
let duration = notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? TimeInterval ?? 0.25
|
||||
|
||||
UIView.animate(withDuration: duration, delay: 0, options: .beginFromCurrentState) {
|
||||
self.textView.contentInset.bottom = 0
|
||||
self.textView.verticalScrollIndicatorInsets.bottom = 0
|
||||
self.floatingDoneButtonBottomConstraint.constant = -16
|
||||
self.floatingDoneButton.alpha = 0
|
||||
self.view.layoutIfNeeded()
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
textView.becomeFirstResponder()
|
||||
}
|
||||
|
||||
private func setupNavigationBar() {
|
||||
let saveButton = UIBarButtonItem(
|
||||
title: "保存",
|
||||
style: .prominent,
|
||||
target: self,
|
||||
action: #selector(didTapSaveButton)
|
||||
)
|
||||
navigationItem.rightBarButtonItem = saveButton
|
||||
}
|
||||
|
||||
private func setupTextView() {
|
||||
textView = UITextView()
|
||||
textView.translatesAutoresizingMaskIntoConstraints = false
|
||||
textView.backgroundColor = UIColor { traitCollection in
|
||||
traitCollection.userInterfaceStyle == .dark ? .secondarySystemBackground : .white
|
||||
}
|
||||
textView.layer.cornerRadius = 12
|
||||
textView.layer.borderWidth = 0.5
|
||||
textView.layer.borderColor = UIColor.separator.cgColor
|
||||
textView.layer.masksToBounds = true
|
||||
textView.font = UIFont.preferredFont(forTextStyle: .body)
|
||||
textView.textContainerInset = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12)
|
||||
textView.text = clip.text
|
||||
view.addSubview(textView)
|
||||
|
||||
var doneConfig = UIButton.Configuration.glass()
|
||||
doneConfig.title = "完成"
|
||||
doneConfig.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
|
||||
var outgoing = incoming
|
||||
outgoing.font = UIFont.systemFont(ofSize: 17, weight: .semibold)
|
||||
return outgoing
|
||||
}
|
||||
doneConfig.baseForegroundColor = .label
|
||||
doneConfig.cornerStyle = .capsule
|
||||
doneConfig.contentInsets = NSDirectionalEdgeInsets(top: 15, leading: 22, bottom: 15, trailing: 22)
|
||||
floatingDoneButton = UIButton(configuration: doneConfig)
|
||||
floatingDoneButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
floatingDoneButton.alpha = 0
|
||||
floatingDoneButton.addTarget(self, action: #selector(didTapFloatingDoneButton), for: .touchUpInside)
|
||||
view.addSubview(floatingDoneButton)
|
||||
|
||||
let safeArea = view.safeAreaLayoutGuide
|
||||
floatingDoneButtonBottomConstraint = floatingDoneButton.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -16)
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
textView.topAnchor.constraint(equalTo: safeArea.topAnchor, constant: 16),
|
||||
textView.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor, constant: 16),
|
||||
textView.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -16),
|
||||
textView.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor, constant: -16),
|
||||
|
||||
floatingDoneButton.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor, constant: -16),
|
||||
floatingDoneButtonBottomConstraint
|
||||
])
|
||||
}
|
||||
|
||||
@objc private func didTapFloatingDoneButton() {
|
||||
textView.resignFirstResponder()
|
||||
}
|
||||
|
||||
@objc private func didTapSaveButton() {
|
||||
let updatedText = textView.text ?? ""
|
||||
guard !updatedText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
||||
let alert = UIAlertController(title: "提示", message: "文案不能为空。", preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "确定", style: .default))
|
||||
present(alert, animated: true)
|
||||
return
|
||||
}
|
||||
|
||||
var updatedClip = clip
|
||||
updatedClip.text = updatedText
|
||||
|
||||
Task {
|
||||
do {
|
||||
try await ClipStore.shared.update(updatedClip)
|
||||
_ = await MainActor.run {
|
||||
self.navigationController?.popViewController(animated: true)
|
||||
return ()
|
||||
}
|
||||
} catch {
|
||||
await MainActor.run {
|
||||
let alert = UIAlertController(title: "提示", message: "保存失败: \(error.localizedDescription)", preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "确定", style: .default))
|
||||
self.present(alert, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ class ClipInboxViewController: UIViewController {
|
||||
|
||||
private var tableView: UITableView!
|
||||
private var emptyLabel: UILabel!
|
||||
private var archiveButton: UIButton!
|
||||
private var clips: [Clip] = []
|
||||
|
||||
override func viewDidLoad() {
|
||||
@@ -20,8 +21,10 @@ class ClipInboxViewController: UIViewController {
|
||||
view.backgroundColor = .systemGroupedBackground
|
||||
|
||||
setupNavigationBar()
|
||||
setupArchiveButton()
|
||||
setupTableView()
|
||||
setupEmptyLabel()
|
||||
setupAppStateObserver()
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
@@ -29,6 +32,23 @@ class ClipInboxViewController: UIViewController {
|
||||
loadClips()
|
||||
}
|
||||
|
||||
deinit {
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
|
||||
private func setupAppStateObserver() {
|
||||
NotificationCenter.default.addObserver(
|
||||
self,
|
||||
selector: #selector(appDidBecomeActive),
|
||||
name: UIApplication.didBecomeActiveNotification,
|
||||
object: nil
|
||||
)
|
||||
}
|
||||
|
||||
@objc private func appDidBecomeActive() {
|
||||
loadClips()
|
||||
}
|
||||
|
||||
private func setupNavigationBar() {
|
||||
let clearButton = UIBarButtonItem(
|
||||
title: "清空",
|
||||
@@ -53,10 +73,58 @@ class ClipInboxViewController: UIViewController {
|
||||
tableView.topAnchor.constraint(equalTo: view.topAnchor),
|
||||
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||
tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
|
||||
tableView.bottomAnchor.constraint(equalTo: archiveButton.topAnchor, constant: -16)
|
||||
])
|
||||
}
|
||||
|
||||
private func setupArchiveButton() {
|
||||
var config = UIButton.Configuration.filled()
|
||||
config.title = "归档"
|
||||
config.baseBackgroundColor = .systemBlue
|
||||
config.baseForegroundColor = .white
|
||||
config.cornerStyle = .medium
|
||||
config.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16)
|
||||
|
||||
archiveButton = UIButton(configuration: config)
|
||||
archiveButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
archiveButton.addTarget(self, action: #selector(didTapArchiveButton), for: .touchUpInside)
|
||||
view.addSubview(archiveButton)
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
archiveButton.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 16),
|
||||
archiveButton.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -16),
|
||||
archiveButton.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -16),
|
||||
archiveButton.heightAnchor.constraint(equalToConstant: 52)
|
||||
])
|
||||
}
|
||||
|
||||
@objc private func didTapArchiveButton() {
|
||||
guard clips.count >= 2 else {
|
||||
let alert = UIAlertController(title: "提示", message: "至少需要两条文案才能归档。", preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "确定", style: .default))
|
||||
present(alert, animated: true)
|
||||
return
|
||||
}
|
||||
|
||||
let title = self.archiveTitle()
|
||||
let itemsText = clips.map { "\($0.text)\n\n---" }.joined(separator: "\n\n")
|
||||
let archivedText = "\(title)\n\n\(itemsText)"
|
||||
let viewController = FormatNoteViewController()
|
||||
viewController.initialText = archivedText
|
||||
navigationController?.pushViewController(viewController, animated: true)
|
||||
}
|
||||
|
||||
private func archiveTitle() -> String {
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.locale = Locale(identifier: "zh_CN")
|
||||
dateFormatter.dateFormat = "yyyy年MM月dd日"
|
||||
let dateString = dateFormatter.string(from: Date())
|
||||
let weekdays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
|
||||
let weekdayIndex = Calendar.current.component(.weekday, from: Date()) - 1
|
||||
let weekday = (weekdayIndex >= 0 && weekdayIndex < weekdays.count) ? weekdays[weekdayIndex] : ""
|
||||
return "【读书摘抄】\(dateString) \(weekday)"
|
||||
}
|
||||
|
||||
private func setupEmptyLabel() {
|
||||
emptyLabel = UILabel()
|
||||
emptyLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||
@@ -96,6 +164,7 @@ class ClipInboxViewController: UIViewController {
|
||||
let isEmpty = clips.isEmpty
|
||||
emptyLabel.isHidden = !isEmpty
|
||||
tableView.isHidden = isEmpty
|
||||
archiveButton.isHidden = isEmpty
|
||||
}
|
||||
|
||||
@objc private func didTapClearButton() {
|
||||
@@ -154,8 +223,7 @@ class ClipInboxViewController: UIViewController {
|
||||
}
|
||||
|
||||
private func openClip(_ clip: Clip) {
|
||||
let viewController = FormatNoteViewController()
|
||||
viewController.initialText = clip.text
|
||||
let viewController = ClipEditViewController(clip: clip)
|
||||
navigationController?.pushViewController(viewController, animated: true)
|
||||
}
|
||||
|
||||
@@ -178,8 +246,10 @@ extension ClipInboxViewController: UITableViewDataSource {
|
||||
|
||||
var config = cell.defaultContentConfiguration()
|
||||
config.text = previewText(for: clip.text)
|
||||
config.textProperties.numberOfLines = 0
|
||||
config.secondaryText = formattedDate(clip.createdAt)
|
||||
config.secondaryTextProperties.color = .secondaryLabel
|
||||
config.textToSecondaryTextVerticalPadding = 12
|
||||
cell.contentConfiguration = config
|
||||
cell.accessoryType = .disclosureIndicator
|
||||
|
||||
@@ -187,9 +257,7 @@ extension ClipInboxViewController: UITableViewDataSource {
|
||||
}
|
||||
|
||||
private func previewText(for text: String) -> String {
|
||||
let lines = text.components(separatedBy: .newlines)
|
||||
let firstTwoLines = Array(lines.prefix(2))
|
||||
let preview = firstTwoLines.joined(separator: " ").trimmingCharacters(in: .whitespaces)
|
||||
let preview = text.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if preview.isEmpty {
|
||||
return "(无内容)"
|
||||
}
|
||||
|
||||
+25
-5
@@ -21,6 +21,17 @@ struct Clip: Codable, Identifiable, Equatable, Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
enum ClipStoreError: Error, LocalizedError {
|
||||
case appGroupUnavailable
|
||||
|
||||
var errorDescription: String? {
|
||||
switch self {
|
||||
case .appGroupUnavailable:
|
||||
return "无法访问 App Group 容器,请检查签名和 entitlements 配置。"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
actor ClipStore {
|
||||
|
||||
static let shared = ClipStore()
|
||||
@@ -31,13 +42,13 @@ actor ClipStore {
|
||||
|
||||
private var cachedClips: [Clip]?
|
||||
|
||||
private var fileURL: URL {
|
||||
private func fileURL() throws -> URL {
|
||||
let fileManager = FileManager.default
|
||||
guard let containerURL = fileManager.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier) else {
|
||||
fatalError("无法访问 App Group 容器: \(appGroupIdentifier)")
|
||||
throw ClipStoreError.appGroupUnavailable
|
||||
}
|
||||
let directoryURL = containerURL.appendingPathComponent(subdirectory, isDirectory: true)
|
||||
try? fileManager.createDirectory(at: directoryURL, withIntermediateDirectories: true)
|
||||
try fileManager.createDirectory(at: directoryURL, withIntermediateDirectories: true)
|
||||
return directoryURL.appendingPathComponent(fileName)
|
||||
}
|
||||
|
||||
@@ -55,7 +66,7 @@ actor ClipStore {
|
||||
return cached
|
||||
}
|
||||
|
||||
let url = fileURL
|
||||
let url = try fileURL()
|
||||
let fileManager = FileManager.default
|
||||
guard fileManager.fileExists(atPath: url.path) else {
|
||||
cachedClips = []
|
||||
@@ -68,6 +79,15 @@ actor ClipStore {
|
||||
return clips
|
||||
}
|
||||
|
||||
func update(_ clip: Clip) async throws {
|
||||
var clips = try await loadAll()
|
||||
guard let index = clips.firstIndex(where: { $0.id == clip.id }) else {
|
||||
return
|
||||
}
|
||||
clips[index] = clip
|
||||
try await persist(clips)
|
||||
}
|
||||
|
||||
func delete(id: UUID) async throws {
|
||||
var clips = try await loadAll()
|
||||
clips.removeAll { $0.id == id }
|
||||
@@ -84,7 +104,7 @@ actor ClipStore {
|
||||
}
|
||||
|
||||
private func persist(_ clips: [Clip]) async throws {
|
||||
let url = fileURL
|
||||
let url = try fileURL()
|
||||
let data = try JSONEncoder().encode(clips)
|
||||
try data.write(to: url, options: .atomic)
|
||||
cachedClips = clips
|
||||
|
||||
@@ -35,10 +35,6 @@ class FormatNoteViewController: UIViewController {
|
||||
setupUI()
|
||||
if let initialText = initialText {
|
||||
textView.text = initialText
|
||||
isNoteFormatted = true
|
||||
noteButton.setTitle("复制并打开备忘录", for: .normal)
|
||||
rightBarButtonMode = .reset
|
||||
updateRightBarButtonItem()
|
||||
}
|
||||
setupKeyboardObservers()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// NoteAppShortcuts.swift
|
||||
// Note
|
||||
//
|
||||
// Created by Kimi Code CLI on 2026/7/15.
|
||||
//
|
||||
|
||||
import AppIntents
|
||||
|
||||
struct NoteAppShortcuts: AppShortcutsProvider {
|
||||
|
||||
static var appShortcuts: [AppShortcut] {
|
||||
AppShortcut(
|
||||
intent: SaveClipIntent(),
|
||||
phrases: ["保存剪贴板到 ${applicationName}"],
|
||||
shortTitle: "保存剪贴板",
|
||||
systemImageName: "doc.text"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,14 @@
|
||||
//
|
||||
|
||||
import AppIntents
|
||||
import UIKit
|
||||
|
||||
struct SaveClipIntent: AppIntent {
|
||||
|
||||
static var title: LocalizedStringResource = "保存剪贴板到 Note"
|
||||
static var description: IntentDescription? = "将一段文本保存到 Note App 的收集箱,稍后统一处理。"
|
||||
|
||||
@Parameter(title: "文案", description: "要保存的文本内容", requestValueDialog: "请提供要保存的文案")
|
||||
@Parameter(title: "文案", description: "要保存的文本内容", default: "")
|
||||
var text: String
|
||||
|
||||
@Parameter(title: "来源", description: "文案来源,例如应用名称", default: "快捷指令")
|
||||
@@ -26,7 +27,14 @@ struct SaveClipIntent: AppIntent {
|
||||
}
|
||||
|
||||
func perform() async throws -> some IntentResult & ReturnsValue<String> {
|
||||
let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
var inputText = text
|
||||
if inputText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
inputText = await MainActor.run {
|
||||
UIPasteboard.general.string ?? ""
|
||||
}
|
||||
}
|
||||
|
||||
let trimmed = inputText.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
guard !trimmed.isEmpty else {
|
||||
return .result(value: "文案为空,未保存。")
|
||||
}
|
||||
@@ -35,7 +43,8 @@ struct SaveClipIntent: AppIntent {
|
||||
return .result(value: "剪贴板没有有效文本,未保存。")
|
||||
}
|
||||
|
||||
try await ClipStore.shared.save(text: trimmed, source: source)
|
||||
let formattedText = TextFormatter.formatForShortcut(trimmed)
|
||||
try await ClipStore.shared.save(text: formattedText, source: source)
|
||||
return .result(value: "已保存到收集箱。")
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
enum TextFormatter {
|
||||
|
||||
static func formatLog(_ text: String) -> String {
|
||||
static nonisolated func formatLog(_ text: String) -> String {
|
||||
var content = text
|
||||
|
||||
content = content.replacingOccurrences(of: "# ", with: "")
|
||||
@@ -31,7 +31,14 @@ enum TextFormatter {
|
||||
return content
|
||||
}
|
||||
|
||||
static func formatForCloud(_ text: String) -> String {
|
||||
static nonisolated func formatForCloud(_ text: String) -> String {
|
||||
var content = formatForShortcut(text)
|
||||
content = "# " + content
|
||||
content = insertEmptyLineAfterFirstLine(content)
|
||||
return content
|
||||
}
|
||||
|
||||
static nonisolated func formatForShortcut(_ text: String) -> String {
|
||||
var content = text
|
||||
content = content.replacingOccurrences(of: " ", with: "")
|
||||
content = content.replacingOccurrences(of: " ", with: "")
|
||||
@@ -71,12 +78,10 @@ enum TextFormatter {
|
||||
content = content.replacingOccurrences(of: " ", with: "")
|
||||
content = content.replacingOccurrences(of: "---", with: "---\n")
|
||||
content = content.replacingOccurrences(of: "日星期", with: "日 星期")
|
||||
content = "# " + content
|
||||
content = insertEmptyLineAfterFirstLine(content)
|
||||
return content
|
||||
}
|
||||
|
||||
static func formatForNote(_ text: String) -> String {
|
||||
static nonisolated func formatForNote(_ text: String) -> String {
|
||||
var content = text
|
||||
content = content.replacingOccurrences(of: "# ", with: "")
|
||||
content = content.replacingOccurrences(of: "#", with: "")
|
||||
@@ -111,13 +116,13 @@ enum TextFormatter {
|
||||
return result.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
}
|
||||
|
||||
static func removeEmptyLines(_ text: String) -> String {
|
||||
static nonisolated func removeEmptyLines(_ text: String) -> String {
|
||||
let lines = text.components(separatedBy: .newlines)
|
||||
let nonEmptyLines = lines.filter { !$0.trimmingCharacters(in: .whitespaces).isEmpty }
|
||||
return nonEmptyLines.joined(separator: "\n")
|
||||
}
|
||||
|
||||
static func insertEmptyLineAfterFirstLine(_ text: String) -> String {
|
||||
static nonisolated func insertEmptyLineAfterFirstLine(_ text: String) -> String {
|
||||
var lines = text.components(separatedBy: .newlines)
|
||||
if !lines.isEmpty {
|
||||
lines.insert("", at: 1)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
/* Simplified Chinese localization */
|
||||
Reference in New Issue
Block a user