-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble placing an image at the top of the editor #196
Comments
Definitely difficult to say without any code 😬. I verified that in the SwiftUIDemo, when the document is empty (i.e., its contents is
This is the code that the MarkupDelegate invokes to bring up the popover next to the insert-image button. The If this isn't the issue, then following the flow of the DemoContentView, I use |
The problem is only when I insert an image at the very top of a new document. I hadn't been sure what to put in a new, empty document and had been using a pair of P tags with a non-breaking space in between. Thanks for the clarification that it should be a BR. When I put some text first and then an image, the HTML comes out simply includes a nice IMG tag for the image, like it's supposed to. When I put an image before anything else I get this curious tag:
I'm using an image picker instead of the popover, so I'll look into your previous comment. |
That content is badly wrong and indicates to me that the |
Okay, I've been looking at the sample project, but still can't figure it out, partly because I have a different interface into the Markup editor. I have a scrolling list of existing documents, when the user taps on one, I need to load that into the Markup Editor. I also have a New button, which I use to create a new document. Here's how I call the editor:
Before that call I load up theCurrentLog.logMarkupHTML with the contents of the document they've selected from the picker or, if they've hit the New button, I put in As you can see, Ive had to add some additional properties to MarkupEditor to get some layout and formatting stuff done. At no time am I calling MarkupEditor.selectedWebView?.emptyDocument() anywhere. Does that make the problem any clearer? |
Sorry to just come back with generic debugging advice on this, but this just mainly says to me that something is going on either in the parts loading When I find myself this kind of situation (which with SwiftUI is more often than I want to admit), I am usually forced into starting from a working version in a completely new project, and progressively copy/pasting in the pieces in that make mine different. For example, I'd build a little view that uses the FileToolbar from the demo, and make sure that creating a new document followed by image insert works properly. Then I'd add a button for the photo picker and make that work properly. None of that would include any of the mods to MarkupEditorView you've made, just the vanilla MarkupEditor from main with code added to support the photo picker. Then I'd maybe find a way to fold-in your I was thinking about kicking this off myself, maybe just to get thru the use of the photo picker, to see if that uncovered anything, but I'm not sure that would help you, other than maybe give us a common set of code to look at for debugging. If that would help, I can do that and we can go from there. |
Okay, I put together a demo of using the photo picker with the vanilla MarkupEditor and put it in this gist. If you use the MarkupEditor demo, then you can add all the files from the gist and put the I moved the minimum deployment target to 16.0 so I could use the SwiftUI PhotosPicker because it seems easiest. Anyway, maybe we can use this as a concrete example of code we can both see to discuss the problem as I was outlining above. Otherwise, I am always reduced to wild ass guesses about what's going on. |
But wild ass guesses are the only way I ever get anything done! Thanks for this, and thanks for the debugging advice, it's all very helpful. I'll go play around with this and see what I can find out. In the meantime, I've gotten embroiled in a problem in another part of the code (not related to MarkUp Editor) so it might be a couple of days. Thanks again! |
I'm having some scope troubles with this code, but it might be because I'm not putting some things in the right place. I stuck PhotoPickerDelegate and PhotoPickerToolbar into my local MarkupEditor dependency. I put PhotoPickerDemo in my project and set up my SceneDelegate. I tacked the MarkupWKWebView extension (the one with insertPhotosItem) onto the end of the PhotoPickerDemo file but it's throwing but it's throwing an error saying it can't find baseURL in the let cachedImageURL statement. I tried moving that extension into the dependency, but then it couldn't find it. Meanwhile, the .pick modifies in the PhotoPickerDemo are also throwing troubles. Sorry if these are obvious things – I've not worked much with Packages before, so I'm a little confused about scope. |
I used a cloned MarkupEditor repo and started from the .xcworkspace that includes the demos. I probably should have started with a clean repo and used the package. So, to make it easier, I created a new public repo for this that only has the package dependency. I removed the usage of This missing |
I'm trying to get sync'd and merged with your latest version, but have run into a little problem due to a customization I made to ToolbarImageButton. It looks like systemNameToButtonName(systemName: systemName!) is no longer working as a way to specify a button name. What can I use instead? This is the routine I was using before:
|
|
Sorry, I hit send before I was ready on that last message. I see that your insertPhotosItem function creates a cached image and then ultimately calls insertImage. I've got my own routine for creating a cached image, because I'm interfacing with a CoreData store and needing to make some little thumbnail files and things. After that I've been calling markupImageToAdd. I never do call insertImage. Could that be a problem? Again, I'm successfully inserting images, as long as there's some text in the document before the image button is pressed. |
Well, |
I guess the bottom line is: yes, you should be calling |
I've pretty much got everything in the editor working the way that I need, but I've run into one odd problem. If I place an image before typing any text, the image doesn't appear. Curiously, if I go back into the photo picker, that image is checked – so some part of the system knows it's been dealt with.
I know this is an abstract question to answer without seeing any code, but do you have any ideas where I might start looking for trouble?
The text was updated successfully, but these errors were encountered: