Open core-ai-bot opened 3 years ago
Comment by chrismatheson Wednesday Nov 13, 2013 at 20:54 GMT
large dump of convo with@
peterflynn
[20:36:32] @
pflynn playing about writing a new extension
[20:36:52] @
pflynn here are some docs: https://github.com/adobe/brackets/wiki/Extension-Unit-Tests
[20:37:45] Matt (48180a75@gateway/web/freenode/ip.72.24.10.117) joined the channel.
[20:38:08] Matt is now known as Guest36206
[20:38:45] Guest36206 (48180a75@gateway/web/freenode/ip.72.24.10.117) left IRC. (Client Quit)
[20:39:14] @
pflynn oh -- might want to hold off on using that API just yet, as we haven't made it official
[20:41:44]@
pflynn it actually can't show anything other than the current 'image preview' viewer right now -- it's hardcoded
[20:42:25] @
pflynn and I think closeCustomViewer() isn't normally an API you'd call directly
[20:42:32] @
pflynn you want the FILECLOSE command
[20:42:43]@
pflynn hmm.. how are you getting it to show?
[20:42:58] @
pflynn out of curiosity, what's it going to view?
[20:44:53] @
pflynn interesting... fyi there's a popular 'markdown preview' extension that might already cover what you want for readme type stuff
[20:45:32] @
pflynn the other caveat you should be aware of if that viewers are ONLY viewers -- they can't edit anything
[20:45:59]@
pflynn oh ok, that's an interesting
[20:46:00] @
pflynn interesting idea
[20:46:16] @
pflynn might be worth filing a bug on the existing markdown extension for that too
[20:46:56]@
pflynn I know a lot of people use it
[20:46:58] @
pflynn but for custom viewers... I tink you'll run into a bunch of problems since the APIs you're calling aren't really supposed to be called directly
[20:47:28]@
pflynn they should probably have an "_" prefix
[20:47:37] @
pflynn soon as i figure out a decent way of doing the render via GH ill do a PR for it and see what the author thinks :)
[20:47:44]@
pflynn cool!
[20:48:02]@
pflynn how about this: could you file a bug saying custom viewers aren't extensible, and then I'll see if we can get that improved for you next sprint?
[20:48:09] @
pflynn hmm.. where did it say "public"?
[20:48:36] @
pflynn there's no supported way to do that yet, hence the bug
[20:49:04] @
pflynn ah ok, good point
[20:49:35]@
pflynn ok yeah, so can you file a bug? that whole API should be cleaned up so it's properly usable and not all confusing/misleading like it is now
[20:49:53]
Comment by njx Monday Nov 18, 2013 at 19:17 GMT
Low pri to@
couzteau to weigh in on whether this is something we could do relatively easily as a bug fix, or whether some more extensive restructuring would be required in order to make this a clean api. /cc@
peterflynn for his opinion as well.
Comment by couzteau Saturday Jan 11, 2014 at 02:21 GMT
The API has evolved since this bug was filed. There is a new API called registerCustomViewer in EditorManager that allows to register customViewers from an extension. There is JSDoc to document the process.
Bottom line is that you'll want to associate you custom viewer with a file extension by registering it with EditorManager. Then When a file is open via the FILE_OPEN command Brackets knows that your extension can display that type of file. You might want to review the JSDoc on registerCustomViewer
Looking at the code of your (@chrismatheson) extension, I think there may be a twist. CustomViewers are supposed to be invoked via FILE_OPEN, not from a button in the toolbar. While that is an interesting idea, that's not how it was designed but I think it may be possible. Check out how DocumentCommandHandlers calls it.
I do expect some issues with how the project tree interacts with the custom viewer in that case as it's expecting the view to be a representation of a file in the project tree.
That said, not sure if there won't be pitfalls but I suggest you to come back if you have further questions.
Comment by couzteau Saturday Jan 11, 2014 at 02:23 GMT
That said. There may be sufficient documentation on the custom viewer related APIs. But I'm happy to take another look at it and I'm sure I'll find ways to improve it too. But if the docs are fine I think this bug may be closed.
Comment by chrismatheson Monday Jan 13, 2014 at 09:51 GMT
This is great, thanks for the help. Hopefully ill find some time soon to actually finish & publish my extension :smile:
Comment by peterflynn Monday Jan 13, 2014 at 21:28 GMT
@
couzteau We should make showCustomViewer()
and closeCustomViewer()
have underscore prefixes -- everyone should just go through registerCustomViewer()
, right? Reopening so we can do that API cleanup.
Comment by peterflynn Monday Jan 13, 2014 at 21:31 GMT
Re@
chrismatheson's extension specifically: I think it can just register itself as a custom viewer and then call FILE_OPEN whenever it wants to view the special file type (e.g. on toolbar button click). However, if the file type should normally be shown as text and it's only going to show up as a static graphical preview at certain times (e.g. it shows as text when opened directly, but shows as preview when toolbar button clicked), then custom viewers aren't really the right solution. A bottom panel like in MarkdownPreview is the better choice in that situation.
Comment by chrismatheson Monday Jan 13, 2014 at 21:46 GMT
I would agree with everything should use the register custom viewer.
How do you think directories/folders could be registered? I know this is my specific use case.
On 13 Jan 2014, at 21:29, Peter Flynn notifications@github.com wrote:
@
couzteau We should make showCustomViewer() and closeCustomViewer() have underscore prefixes -- everyone should just go through registerCustomViewer(), right? Reopening so we can do that API cleanup.— Reply to this email directly or view it on GitHub.
Comment by couzteau Tuesday Jan 14, 2014 at 01:17 GMT
posted pull to prefix the functions mentioned by@
peterflynn
https://github.com/adobe/brackets/pull/6511
Comment by couzteau Tuesday Jan 14, 2014 at 01:23 GMT
I agree that the use case described doesn't fit the intended use case of the custom viewer well. The intended custom viewer use case will show a view by means of a custom viewer for a file that the code mirror editor cannot show, such as binary files. Registering a viewer means to associate the viewer with one or more file types by defining a language or mode for a number of file extensions.
PackageViewer wants to display a styled view of an aggregate of information from various files. Hence I don't think we have a good fit.
Comment by couzteau Monday Mar 17, 2014 at 21:30 GMT
@
peterflynn There is asimple pull request up for this. It just renames the methods per your suggestion.
Comment by chrismatheson Monday Mar 17, 2014 at 21:42 GMT
Thanks for the help here guys, moved my extension to a Bottom panel instead, seems to be working well.
Comment by peterflynn Thursday Mar 20, 2014 at 23:43 GMT
The non-public APIs are now underscore-prefixed. Thanks for the cleanup@
couzteau!
Issue by chrismatheson Wednesday Nov 13, 2013 at 20:53 GMT Originally opened as https://github.com/adobe/brackets/issues/5985
Hi,
I'm trying to write an extension that will change the editor into a custom view & then return after. somewhat similar to a modal expect not a modal.
I've found a few API's in the code but I've been waved off them as they are not 100% public yet.
Could someone look into this and let me know the blessed path for doing this kind of thing?