khoi / codemirror-swift Goto Github PK
View Code? Open in Web Editor NEWπͺ Swift wrapper for CodeMirror 6
License: MIT License
πͺ Swift wrapper for CodeMirror 6
License: MIT License
Would it be possible to update CodeMirror to the latest 6.x version? There's a function in there I'm trying to use called scopeCompletionSource
, but it doesn't seem to be available in this version.
I'm trying to configure autocomplete to trigger when you type in the .
character and then display a list of context sensitive completions pertaining to the token typed before the .
Here's a link to the mention of it:
https://github.com/codemirror/lang-javascript/#user-content-scopecompletionsource
Thanks!
Thanks for putting this package together!
I've run into a couple of issues I wanted to make you aware of. [I considered opening a separate issue for the compilation issues, vs. the SPM package search issue - you will probably want to track them separately. But I don't want to clutter your issues list.]
When I try loading your package Xcode points to a different package than the url you provided, my guess is that both these packages are being searched for in a non-case-specific way, so they look the same. (CodeMirror-Swift
vs codemirror-swift
)
I specify https://github.com/khoi/codemirror-swift
, but this link appears in Xcode
https://github.com/ProxymanApp/CodeMirror-Swift
- which does not use CodeMirror 6.0
I tried using your url inside a Package.swift file in a local package instead [this worked], and the package doesnβt compile due to these errors:
CodeMirrorWebView.swift:39:43: error: cannot find type 'NSRect' in scope
and
CodeMirrorWebView.swift:39:21: error: initializer does not override a designated initializer from its superclass
It looks like these two lines need to conditionally compile based on when using AppKit, vs using UIKit/SwiftUI.
Something like this would solve that:
#if os(OSX)
import AppKit
public typealias NativeRect = NSRect
#elseif os(iOS)
import UIKit
public typealias NativeRect = CGRect
#endif
There's a third issue with the main module, which I haven't researched/resolved, so I'm using a workaround:
CodeMirrorWebView.swift:98:17: error: value of type 'WKWebView' has no member 'allowsMagnification'
Since WKWebView does not have an allowsMagnification
property, I commented it out.
With these errors corrected, the test module fails:
codemirror-swift-main/Tests/CodeMirrorTests/CodeMirrorTests.swift:10:24: error: cannot call value of non-function type 'module<CodeMirror>'
XCTAssertEqual(CodeMirror().text, "Hello, World!")
By commenting out the assertion I did get a successful compile. This is not a final solution but it allows me to try to actually use your package.
I'll let you know how I make out when I swap in your package to my existing app (which uses CodeMirror 5.x).
After making those 3 changes the package successfully compiles
I'd like to be able to add in my own autocompletions to the list of available ones.
Do you know how to do that? The documentation on the CodeMirror 6 website is not very clear on how to put it all together.
I've been trying to put some of the examples into your editor.js
file, but I end up getting compile errors.
Do you know how to extend the list of autocompletions?
It should be trivial to implement one, I never find the need for it so if you're reading this, please submit a PR π
I've been researching the documentation and online examples of how to change the font size, but most of the information I can find is very old and applies to CodeMirror 5. I'm using this package with CodeMirror 6 now but cannot figure out how to provide the ability to dynamically change the font size. I want a font size slider to control the font size.
If I put a fontSize: 13pt;
item into the baseTheme
constant then I can see the new font size. But I want to make that dynamic.
Do you know how to do that?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.