qeude / swiftdown Goto Github PK
View Code? Open in Web Editor NEW📦 A themable markdown editor component for your SwiftUI apps.
License: MIT License
📦 A themable markdown editor component for your SwiftUI apps.
License: MIT License
Hi! I am experiencing a cursor jump to the end of text on each formatting being applied. Anything I could do to stop this from happening?
After add dependency i always receive this error
Failed to resolve dependencies Dependencies could not be resolved because package 'swiftdown' is required using a stable-version but 'swiftdown' depends on an unstable-version package 'swiftlint' and root depends on 'swiftdown' 0.3.0.
Describe the bug
I started attempting to integrate SwiftDown into a cross-platform SwiftUI project that utilizes a NavigationSplitView, and noticed an odd behavior where SwiftDown seems to always be referencing an older item. I've tried many different variations of utilizing NavigationSplitView, but all of them exhibit this issue. If I use the deprecated NavigationView instead, this problem does not occur.
To Reproduce
Here's some sample code to show off the issue: https://gist.github.com/garrettmurray/4e23b2478f89beae47913a78d9c194a2
You'll note that only the SwiftDown field suffers from this issue—editing via the TextEditor in the same VStack appropriately updates the correct, currently-selected item.
Expected behavior
SwiftDown field would edit the correct item's text, like TextEditor does.
Screenshots
Attaching a video of this bug in action as well, using the sample code linked above.
Desktop (please complete the following information):
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
toMarkdownNode
method in MarkdownEngine.swift
error: Swift/StringUTF8View.swift:192: Fatal error: String index is out of bounds
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
I have been unable to find a text editor, where markdown can be applied programmatically, but without markdown characters visible. For example, similar to the way you can make text bold in the Apple Notes app.
Is this possible with SwiftDown?
PS:
Theme is customized.
Any idea why I'm getting this error when I try to add it via Package Manager?
Failed to resolve dependencies Dependencies could not be resolved because root depends on 'swiftdown' 0.3.0..<1.0.0
Describe the bug
Adding the package to my iOS 16 project causes the error Plug-in ended with uncaught signal: 5)
To Reproduce
Steps to reproduce the behavior:
Additional context
I'm using Version 14.3.1 on a project for iOS 16
Currently, the repo doesn't have a license yet.
Is your feature request related to a problem? Please describe.
One expectation of a Markdown preview is that links are actually clickable when they're identified and displayed as links.
Describe the solution you'd like
Two possible ways to solve this as I think about it (conveniently without any concern about implementation 😆):
A. Add logic to wrap detected link nodes in their link so that the entire [Text](https://link)
is linked as a single unit (this seems complex).
Or
B. Allow for the isAutomaticLinkDetectionEnabled
attribute of NSTextView
to be utilized (and the UIDataDectorTypes.link
equivalent on iOS) which would only link the actual URL from the link, but would at least still make the link clickable.
Seems like B would be much easier and get 90% of the way there, though it's less accurate to the preview technically. Would still be preferable, I think, to no linking at all, however.
Describe alternatives you've considered
Obviously, this isn't a blocker to using SwiftDownEditor, but it does mean one of the core features of Markdown doesn't actually do anything when you match it, which is odd.
Is your feature request related to a problem? Please describe.
Currently, SwiftDownEditor stores the theme internally, and therefore the theme is not able to be changed from the outside. For modern apps which support light and dark mode, this means any SwiftDownEditors in use will always be stuck with the theme they were created with, which leads to a poor user experience.
Describe the solution you'd like
Ideally, setting the theme would redraw the SwiftDownEditor, such that you could base the current theme on the environment's color scheme to automatically support light/dark modes. This would also allow for a user to change themes while utilizing the editor, with, say, a drop-down of available themes.
Describe alternatives you've considered
Without this, the SwiftDownEditor would need to effectively be removed from the hierarchy, and recreated, which doesn't feel very SwiftUI-like.
Additional context
A quick example of what I expected to do for supporting system-wide dark/light mode:
@Environment(\.colorScheme) var colorScheme
SwiftDownEditor(text: $itemText)
.insetsSize(20)
.theme(colorScheme == .dark ? Theme.BuiltIn.defaultDark.theme() : Theme.BuiltIn.defaultLight.theme())
.debounceTime(0.5)
I was taking a look at the package and noticed a weird behavior when typing the text where its plain text before formatting, I was wondering if you knew of any work arounds.
I was also wondering where the popover to insert an emoji was from.
Can you release a swift package of the markdown engine? as in, an independent library I can import to use your markdown styling.
For example, I'd like to use something like this:
import SwiftDownMD
struct Comment: View {
let comment: Comment
var body: some View {
VStack {
Markdown(comment.body)
}
}
}
See error in accessor code: isEditable is set to true
whatever value is passed :
public func isEditable(_ isEditable: Bool) -> Self {
var editor = self
editor.isEditable = true // <-- here
return editor
}
import SwiftUI
import SwiftDown
struct DownTest: View {
@State private var text: String = "Reply"
var body: some View {
VStack {
SwiftDownEditor(text: $text).frame(height: 50)
TextField("", text: $text).frame(height: 50)
Button {
self.text = ""
} label: {
Text("Clear")
}
}
}
}
struct DownTest_Previews: PreviewProvider {
static var previews: some View {
DownTest()
}
}
The text should clear as the TextField does when you run this code.
First of all: SwiftDown is a great package! I tried several markdown editor packages that support live styling and SwiftDown has by far the best editing experience.
There is one thing I am struggling with: it appears that styling is only applied when editing text (so typing in the editor), but not when the view is initially loaded. This can be demonstrated when you use navigation in a project, e.g. have a list of documents and when you click on a document, the corresponding contents are being shown in a SwiftDown view. Initially all text has the same color and font size, but if you give SwiftDown focus and type one character, then all styling gets updated.
I tried to fiddle with the .onAppear()
modifier, but is unclear to me how I could trigger 'update styling' in the SwiftDownEditor. Does someone has an idea how to handle this? Thanks in advance!
Hey, I was happy to find this package and wanted to try it in my project. However, I faced some warnings that intrigue me.
Describe the bug
When installing the package, Xcode asks for Keychain access. And then, after refusing it, it shows up the error:
Build plug-ins with malicious code can harm your Mac or compromise your privacy. Be sure you trust the source of build plug-ins before you enable them.
Question
Why does it need access to the keychain? Is this package safe?
In Markdown, the syntax - [ ]
allows you to create todo lists.
How difficult would it be to implement this syntax but with a custom renderer displaying a checkbox.
Is it possible to have the markdown syntax hide as the cursor leaves the text? Sort of like Obsidian does in their live preview mode?
Eg when writing **bold**
to only show bold? (Notice that the asterisks have been "hidden")
Describe the bug
All builds fail because of duplicated symbols when also using MarkdownUI
To Reproduce
Expected behavior
The app builds without compilation errors
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
none
Is there any way to force SwiftDownEditor
to automatically receive the focus on iOS?
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.