百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

CodeMirror-SwiftUI

> 开发工具
开源

CodeMirror-SwiftUI 是一个针对 SwiftUI 打包的轻量级 CodeMirror 封装,适用于 macOS 和 iOS。

99 stars0 点赞4 次浏览
访问官网GitHub

工具介绍

CodeMirror-SwiftUI 是一个针对 SwiftUI 打包的轻量级 CodeMirror 封装,适用于 macOS 和 iOS。

CodeMirror-SwiftUI

CodeMirror-SwiftUI is a lightweight wrapper of CodeMirror for macOS and iOS packaged for SwiftUI.

This package is a fork from CodeMirror-Swift

Features

  • Lightweight CodeMirror wrapper (build 5.59.4)
  • ✅ 100% Native Swift 5 and modern WKWebView
  • Support iOS & macOS
  • Built-in addons
  • 100+ built-in themes and syntax highlight modes
  • ⚡️ Ready to go

Requirements

  • Xcode 12
  • Swift 5.3

Integration

CodeMirror-SwiftUI is available via Swift Package Manager

Using Xcode 12, go to File -> Swift Packages -> Add Package Dependency and enter https://github.com/Pictarine/CodeMirror-SwiftUI

Usage

CodeMirror gives you access to a new view called CodeView. It can be integrated within your view body like this :

swift
CodeView(theme: themes[selectedTheme],
         code: $codeBlock,
         mode: codeMode,
         fontSize: fontSize,
         showInvisibleCharacters: showInvisibleCharacters,
         lineWrapping: lineWrapping)
.onLoadSuccess {
  print("Loaded")
}
.onContentChange { newCodeBlock in
  print("Content Change")
}
.onLoadFail { error in
  print("Load failed : \(error.localizedDescription)")
}

Details

Code Editor Features

  • CodeMirror v5.59.4
  • Better find and replace dialog integration
  • Autocompletion hints (ctrl+space)
  • Reindent (ctrl+i)
  • Auto close tags and brackets

Parameters

CodeView has multiple params:

Parameter name Optional Type Default
code false Binding
mode false Mode
theme true CodeViewTheme .materialPalenight
fontSize true Int 12 (px)
showInvisibleCharacters true Bool true
lineWrapping true Bool true

Modifiers

CodeView comes with three modifiers

swift
onLoadSuccess { ... }
swift
onLoadFail { ... }
swift
onContentChange { ... }

Demo

  • macOS Demo and iOS Demo are available

  • Snip, a snippet manager for macOS is also using CodeMirror-SwiftUI

License

CodeMirror-SwiftUI is available under the MIT license. See the LICENSE file for more info.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScriptcodemirrorcodemirror-editorswiftswiftui

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具