-
Notifications
You must be signed in to change notification settings - Fork 139
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
Thumbnail and non-image upload support in paste-image #18
Conversation
Maybe generating thumbnail is not essential. A developer may do this in his own uploader function. A better solution just occurred to me: developers who use HyperMD shall be able to use his own placeholder. He can create a inline box, displaying progress bar, thumbnail, upload options etc. Besides, the final Markdown output (for images, What do you think about it? |
Yes, I think it's a good idea - will look into it and update this PR. |
The thumbnail can be a cool example. Here's my plan:
|
I like the proposed changes, they are very good. Unfortunately I won't have time to do all the changes you propose - I'm not very familiar with codemirror yet. Closing this PR since I'm assuming you'd like to work on the insert-file plugin. Just checking to avoid duplicate work - will you add the insert-file plugin? Also, what do you think of using typescript instead of es6? I think there's a lot of benefit, since type checking and easy to transpile too |
Won't be hard to write the add-on. I'll do it tomorrow. TypeScript is a good option, I like it's type-checking but it's UMD style is not cool. Don't know whether Typescript supports plugin/postprocessor |
You can export to es6 from typescript, then just run a preprocessor (e.g. with gulpjs) Here's a quick test with es5 export, can just run in VS code. btw, what do you mean by the "UMD style is not cool?" -> does it miss support for something? |
Did some more research for UMD. TypeScript does not output global namespace for UMD is open discussion: microsoft/TypeScript#8436 I think there are several options for language choice:
Not sure which is best short-term. Perhaps (5.) keep the code as-is and revisit later, because it allows for faster iteration now. On the flipside, here's the InsertAction in typescript. It feels very nice to have the type checking. export interface InsertAction {
/**
*
* @param placeholder A placeholder to show in the markdown
* document during upload or after upload finished
*/
setPlaceholder(placeholder: string | HTMLElement): void;
/**
* If the placeholder's size changes, call to update view
*/
refreshSize(): void;
/**
* When handler's job (uploading) is done, no matter a success or a fail
* (HyperMD doesn't care about the result), this function shall be called.
* Then the placeholder will be removed and replaced with the text
* @param text
*/
finish(text: string): void;
} |
I make a simple working insert-file.ts addon, as we discussed above. Here it is: https://gist.github.com/nokola/f11f91b15ee4acdd17588334e1b57f78 I won't have time to extend it yet, because I have to work on other parts of my project (the actual file upload...) I think it's best that it's part of HyperMD, but I wanted the addon today to continue with my project, so I made this quick/simple one. Please feel free to use as you wish/copy/etc. or just use the .js output! |
fix: Fixed PlantUML support
Added:
Made by adding enableThumbnail option. If enableThumbnail == true, during upload we will show a thumbnail of the image instead of full size. Also, in this case, the uploader(...) function will get both the original file and the thumbnail version, upload both, then return whichever URL (thumbnail or full size) it wants.
Fixed:
Notes:
We can change the fold add-on (or create new add-on, not sure which is best yet) to detect if image ends with _thumb.jpg and Ctrl+Click to display the full image (.jpg)
for example: