Hi,
I'm trying to make markitup work with Markdown. I'm running in to the fact that drupal_add_js() doesn't support passing in a function to evaluate at run time. I know that bigger things are in store for configs, but for now I'm just trying to get something functional. What I've done so far is create a new editor include for the markdown-version of markitup. Then, in the wysiwyg settings, you can choose between "markitup" and "markitup (markdown)" as needed.
To attempt to make functions work, the attached simply looks for strings starting with 'function' and attempts to eval() them. Obviously a better key would need to be used :). The problem though is that the for() loop breaks the anonymous function, as the value is the same for all applied instances.
Any suggestions for how to make this work? Or am I going off track? I really hope that your TODO note means you know how to do it and just haven't done it yet :)
Comment | File | Size | Author |
---|---|---|---|
#37 | wysiwyg-markitup-397994-37.patch | 16.26 KB | jrbeeman |
#34 | 397994-d7-34.patch | 16.29 KB | skh |
#32 | 397994-d7-32.patch | 16.33 KB | redndahead |
#30 | 397994-d7-30.patch | 17 KB | redndahead |
#28 | 397994-d7-28.patch | 16.37 KB | redndahead |
Comments
Comment #1
sunInteresting approach.
No, I don't have a master-plan for that @todo yet. However, since markItUp does
...a possible approach would be to define a call interceptor in JS
But honestly, I don't know.
@see https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Ob...
Comment #2
deviantintegral CreditAttribution: deviantintegral commentedWell, I got closer. To get it to work you have to "seal" variables by copying. However, I then ran into issues of scope; the closure didn't have access to the markItUp object so it couldn't properly query it.
Here what I have so far:
@sun, I couldn't determine what objecto to try attaching that to, as the 'markitup' object doesn't exist.
As I need this working now, I've hard-coded settings into the JS. I've attached that in case anyone else finds it interesting. While this implements the UI still for settings, if you use this note that none of them are actually used.
Comment #3
sunComment #4
deviantintegral CreditAttribution: deviantintegral commentedNo major changes, just rerolling from the module folder as it should be.
Comment #5
jide CreditAttribution: jide commentedGreat to see we go towards more supported editors !
Comment #6
kunago CreditAttribution: kunago commentedI added more buttons. Namely the picture button, color palette, lorem ipsum and preview. The files placed in "markitup-markdown.zip" should go to the "sites/.../modules/wysiwyg/editors" folder. Then I also attached the button pictures (placed in "images.zip") that should go to "all/libraries/markitup/markitup/sets/markdown/images/".
Comment #7
a_c_m CreditAttribution: a_c_m commentedI think the patch in #5 is the best solution so far (however it has one small mistake, on line 13 it had an extra */). However both #5 #6 make assumptions about the location of the libraries folder relative to their current position and so break on my install (were i have contrib. in sites/.../contrib/), so some thought might need to be given to this.
#5 implements all the buttons made available by the stock markdown set available on the markitup site. However i think we should look for a more complete button set (as http://drupal.org/project/markdowneditor has).
Additionally (for what its worth), i REALLY dont like the popup method of adding URLS (i think just injecting some text with areas to edit would be better) and the code/blockquote button seems not to work?
Comment #8
a_c_m CreditAttribution: a_c_m commentedwhoops, forgot the patch :)
Comment #9
Encarte CreditAttribution: Encarte commentedsubscribe
Comment #10
tnanek CreditAttribution: tnanek commentedSubscribe
Comment #11
nrambeck CreditAttribution: nrambeck commentedI took the patch from comment 8 and refactored it to work with the latest 7.x-2.x branch.
Comment #12
Jean-Philippe Fleury CreditAttribution: Jean-Philippe Fleury commentedSubscribing
Comment #13
smithmilner CreditAttribution: smithmilner commentedsubscribing
Comment #14
rerooting CreditAttribution: rerooting commentedSuprisingly, this still works, somewhat.
You have to create blank files: editors/markitup_markdown.inc and editors/js/markitup_markdown.js. In a linux environment you can use 'touch path/filename' to do this quickly.
Then, for better support for the icons, markitup's default set no longer comes with header element icons. Thus, grab the markdown set and put it in the appropriate folder in the markitup library.
Then, go to edit editors/js/markitup_markdown.js and change line 64 from:
.css({ backgroundImage: 'url(' + settings.root + 'sets/default/images/' + button + '.png' + ')' })
to:
.css({ backgroundImage: 'url(' + settings.root + 'sets/markdown/images/' + button + '.png' + ')' })
Make sure to clear your cache if you are using javascript aggregation. Enjoy!
Comment #15
ar-jan CreditAttribution: ar-jan commentedThis seems to be the main issue for Markdown support. Has there been any progress?
Does #1650416: Allow editor specific changes to be made to the profile settings form allow improvement for an implementation that lets us chose Markitup sets (or a workaround approach maybe)?
Comment #16
eric.chenchao CreditAttribution: eric.chenchao commentedI have made makeItUp to support more buttons.
Here is the button picture
Here is the setting form. There is a extra field added in the output area called markup type. At the moment, default HTML and markdown are available in the option list.
I have also added a custom button called kbd which will insert . This is very handy when I am documenting some instructions.
How to install
Known issue:
Numeric list button does not work at all, as its "open with" parameter is a function which will become a string in the JavaScript.
Comment #17
ar-jan CreditAttribution: ar-jan commentedNot sure how this relates to the earlier patches, but I guess this needs review.
Comment #18
eric.chenchao CreditAttribution: eric.chenchao commentedno this one does not relate to the earlier patches.
The patch in #11 provide a new editor called makeitup_markdown with markitup_markdown.inc and markitup_markdown.js
This patch does not support button management, which means it will display all regular buttons.
The patch in #16 uses a different approach:
It provides an extra select field - markup type - in the wysiwyg markitup profile admin. So user can switch between default type HTML and markdown. We could add support for other format like BB code in the future for example.
So all buttons could be managed to show up in the admin UI.
Comment #19
eric.chenchao CreditAttribution: eric.chenchao commentedThe updates in patch including:
Also upload the markup set attached in #169 zip file and apply this patch.
Comment #20
eric.chenchao CreditAttribution: eric.chenchao commentedAdd multiple line support for code.
Comment #21
loominade CreditAttribution: loominade commented@#20
I applied your patch with the current dev (7.x-2.2+23-dev) and observed these errors:
Comment #22
eric.chenchao CreditAttribution: eric.chenchao commented@loominade
I have added isset check to fix issue 1:
Regarding the second issue, could you go to `admin/config/content/wysiwyg/profile/filtered_html/edit`, select buttons and choose output as markdown and save the form?
Also clear your cache of js and have a try.
Comment #23
loominade CreditAttribution: loominade commented@eric.chenchao
so far it works fine for me. maybe the Buttons and plugins that are not supported by markItUp! shouldn't be available in the settings form.
Comment #24
redndahead CreditAttribution: redndahead commentedI'm trying this out and it seems that there are missing images in your zip file. Is there a place to download them?
h1.png
h2.png
h3.png
h4.png
h5.png
h6.png
ol.png
ul.png
Clean.png
Comment #25
redndahead CreditAttribution: redndahead commentedWhoops I was wrong. My problem is that the images are pointing to default directory and not the markdown directory. Also since it asks for ol and ul and not list-bullet and list-numeric I think something else is up. Any ideas?
Comment #26
eric.chenchao CreditAttribution: eric.chenchao commented@redndahead you are right. I have renamed these two images.
Comment #27
redndahead CreditAttribution: redndahead commentedI have made a couple of changes with this patch. With this combined patch I was able to add a plugin with some changes to footnotes_wysiwyg so this much more extensible. Thanks eric.chenchao for gettings this going.
I have created an example project on how one can add plugins to this also. You can find it here: https://www.drupal.org/sandbox/redndahead/2294249
Comment #28
redndahead CreditAttribution: redndahead commentedHere is another patch with a few changes.
This example module shows how to add additional sets: https://www.drupal.org/sandbox/redndahead/2294887
Comment #29
redndahead CreditAttribution: redndahead commentedNow hopefully the last patch. I have updated my plugin example module to support the newest features. https://www.drupal.org/sandbox/redndahead/2294249
This patch is getting pretty large and probably very difficult to review. I'm not sure what the best way to break this up would be though.
Comment #30
redndahead CreditAttribution: redndahead commentedOf course it wasn't the last patch. Clean-up didn't work and link had the wrong class name.
Comment #31
redndahead CreditAttribution: redndahead commentedComment #32
redndahead CreditAttribution: redndahead commentedWhile thinking about this issue #2025625: Allow for custom icon paths in MarkItUp editor and I think I can handle that issue in a better way than I am doing it here. So I have stripped out the part that removes the buttons and it can be dealt with in that other issue. The patch for that issue can be found here: https://www.drupal.org/node/2025625#comment-8931461
Comment #33
TwoDThanks for your effort on this! I don't have time to review it right now, but I just wanted to let you know I'm not ignoring this topic. =)
Comment #34
skh CreditAttribution: skh commentedGreat patch, was looking to add this functionality myself. I can confirm it's working.
There was one warning when configuring the editor for the first time (missed an empty check). Same patch as #32 attached, with that check and newlines in the .js files.
Other issue I'm noticing is with the preview button. Since it doesn't run through drupals text formatting it's just showing plain text. Didn't have any quick ideas for how to remedy this, but if anyone has an idea I'd be willing to give it a shot.
Comment #35
Leeteq CreditAttribution: Leeteq commented(PS. I am unfamiliar with MarkitUp, but curious if there exist a tool that unites "Markdown" and WYSIWYG.)
Will the outcome of this be true WYSIWYG with real bullets instead of stars in the body text edit field as we type, yet saved with a special input format that actually saves bullet lists with stars instead of HTML markup?
Comment #36
C-LogemannI can also confirm that the #34 patch is working except the preview button.
I believe the preview function needs a lot of work. It currently shows html but not markdown code. Especially the linebreak-conversion – which is identical to the core filter for linebreaks-converts – is not displayed. So it is completely useless. Either we remove the preview button or we fix this. So I switch the status to "needs work".
In my opinion we should get the main support of markItup committed soon and maybe discuss and work on the preview functionality in an extra issue.
@Leeteq: Maybe this Editor not really a "wysiwyg"-Editor and I am not sure if this really makes sense. But it's helpful to get this editor working with the "wysiwyg-module" to get this easy working together with other editors.
Comment #37
jrbeemanRe-rolling patch from #34 against latest 7.x-2.x. Applies successfully against wysiwyg-7.x-2.4.