DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:inlineeditor

inlineeditor Plugin

Compatible with DokuWiki

2011-05-25

plugin Inline editor directly in the text

Last updated on
2011-11-03
Provides
Syntax, Action
Repository
Source
Conflicts with
dw2pdf, odt

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to dblclickedit, fastwiki, quickedit

Tagged with ajax, editing, inline, javascript

With this plugin you can more easily edit your text by simply double clicking it. This will give you an inline editor, as seen here:

(see a movie of how the editor works here: http://www.youtube.com/watch?v=aFeewwa_Tew )

(from http://www.nbtwiki.net)

This plugin is based on the quickedit plugin.

Installation

Search and install the plugin using the Extension Manager or manually with the download from the SourceForge Mirror. Refer to Plugins on how to install plugins manually.

Then to make the toolbar work, you need to make a small change to the /lib/scripts/linkwiz.js

FIXME : don't work in 2012-01-25 “Angua”

Change

        $('dw__editform').parentNode.appendChild(linkwiz.wiz);
        try{
            $('dw__editform').parentNode.appendChild(linkwiz.wiz);
        }
        catch(e){
            $(textArea.id).parentNode.appendChild(linkwiz.wiz);
        }

It is recommend to change the “lock time” to more than 15 mins, in order to avoid locks are running out too quickly. The plugin implements the full locking mechanism for editing - but does not notice the user about expired locks.

Change Log

  • 2011-08-01
    • Initial release
  • 2011-08-02
    • The mediamanger should now work correctly
  • 2011-09-01
    • Some browser compatibility issues were fixed. See discussion below.
  • 2011-10-09
    • Fixing preview bug, see below
  • 2011-10-10
    • Fixed minor issue with the .zip file
  • 2011-11-03
    • Fixed 'isBlank' bug which prevented the editor to work properly

Known issues

  • Might conflict with dw2pdf plugin

Developer?

If you want to improve this plugin I would be very happy to add you as developer with read/write access on sourceforge. Please, contact me with your suggestions and comments.

Some suggestions for further development:

  • Add support for auto-draft-save, auto-lock expired notice
  • Implement editing box using a javascript instead of using the syntax plugin.
  • Add editor auto-indent feature
  • ?

Discussion

It looks like you create a hidden textarea element for every section on the page. If you instead used javascript to generate the text editor when needed, you could name the form “dw_editform,” and the installation hack above wouldn't be necessary. Your plugin would also be faster, since it wouldn't create so much text. In fact, you could just attach a javascript event to the document's ondblclick event, and search up the tree from the event target to a dokuwiki section. Then you wouldn't need the syntax plugin. –zioth

Thanks for the comment. Sounds like a better implementation. –Simon


It seams that this inlineeditor doesn't work with dw2pdf. If I enable the inlineeditor plugin, the output of dw2pdf show the editpage from inlineeditor after every section. – Gerold


We really like this plugin– very convenient to make quick corrections. And it's helped my team warm up to sections, which has been an issue before! But… it doesn't seem to work in IE8, which everyone but me uses. The editor is displayed OK, but clicking the “save” button throws a Javascript error “Object doesn't support this property or method” in js.php?tseed=1313700839, line 1 character 68346. Which is impossible for me to track down– the JS is minimized and not readable. –Randy Whitaker 8/24/2011

Hi Randy, Thanks for the nice comment. Is is possible that you could uncheck the “compress javascrip/CSS” option on the dokuwiki configuration page - and report the line of the IE error? I am on a Mac, - so it is difficult for me to check. –Simon 8/30/2011

In general, you get the same errors on Safari as on IE. You just have to open the error console. -ziothzioth

Hello Simon– Always happy to help. If you can fix this we'll be very grateful. It's line 3709, character 5, message “Object doesn't support this property or method”. I'd include a screenshot but dokuwiki doesn't let me upload an image (which I fully understand). Here's the code (line 3709 is marked):

function quickedit_save(id, range, page)
{
	pl_si.sack.onCompletion = quickedit_save_cb;
    pl_si.sack.URLString = '';
    pl_si.id=id;
    pl_si.page=page;
    minor=document.getElementById("minoredit"+id+page).value; //line 3709!
	text=document.getElementById("wiki__text").value;
	sub=document.getElementById("editsummary"+id+page).value;
	pl_si.sack.runAJAX('call=save_page&range='+range+'&page='+page+'&text='+text.replace(/&/g, '%26')+'&sub='+sub.replace(/&/g, '%26')+'&minor='+minor);
}

-fumigatorRandy Whitaker
fumigator

8/30/2011

Thanks for the help. Probably it is the .value that does not work. However, I just checked in IE 9, and everything works fine. I would recommend to update to the latest version of IE. I didn't check Safari -Simon 8/31/2011

It's more likely that the javascript error happens in every browser, but only with a specific page format or configuration (for example, just one section, or a certain number of sections, or only when using htaccess redirects or something). -ziothzioth

Unfortunately IE9 will not install on Windows XP, and as we are a large corporation, we will only be getting Windows 7 when our machines are replaced (2 years away). Zioth– Firefox does not throw any kind of Javascript error. IE8 throws the error on any and all sections I've ever tested it with. -fumigatorRandy Whitaker
fumigator

8/31/2011

FIX FOUND I was able to fix this error by declaring “minor” as a var (instead of letting that be implied). I did the same for variables text and sub even though they were not causing errors. Good coding practice imo.

function quickedit_save(id, range, page)
{
    pl_si.sack.onCompletion = quickedit_save_cb;
    pl_si.sack.URLString = '';
    pl_si.id=id;
    pl_si.page=page;
    var minor=document.getElementById("minoredit"+id+page).value; //fixed
    var text=document.getElementById("wiki__text").value;
    var sub=document.getElementById("editsummary"+id+page).value;
    pl_si.sack.runAJAX('call=save_page&range='+range+'&page='+page+'&text='+text.replace(/&/g, '%26')+'&sub='+sub.replace(/&/g, '%26')+'&minor='+minor);
}

-fumigatorRandy Whitaker
fumigator

8/31/2011

Hi fumigator! Thanks for the help. I have now updated the plugin with your changes. It should now work for all browsers I hope? If anybody wants to help developing further on this plugin, then please drop me a line (my email is above). – Simon 09/01/2011


We found another fairly severe issue when using this plugin which can result in content loss. When editing a page using the normal “edit page” button, if I click “preview”, and then double-click inside the preview of the page, the inline editor pops up, in addition to the normal editor, but the content in the inline editor textarea is messed up– it is not what's in the section clicked on. The biggest issue with this unintended behavior is if you click the save button on the inline editor, the entire page is wiped out, except what's in the inline editor's textarea. I've done this a couple of times– I forget I'm looking at a preview instead of the normal page, see something that needs changing, double-click it (since I'm so used to using inline editor now), and if I don't realize what's happening, I save and wipe out the page. The best way to fix this would be to remove the double-click functionality when the page is is a preview (have no idea if that's possible). -fumigatorRandy Whitaker
fumigator

8/31/2011

Hi fumigator. Sorry for late answer, but I do not check this page every day. The preview bug is now fixed. – Simon 10/09/2011


Thanks for the neat plugin, Simon! Unfortunately, it seems to eat '+' signs so it doesn't work for me in my math-intensive wiki (using plugin:jsmath). Before editing I might have a + b but after saving it becomes a b. It looks like the plus-symbol needs to be encoded before save. There could be other characters that also need to be encoded so I changed

    pl_si.sack.runAJAX('call=save_page&range='+range+'&page='+page+'&text='+text.replace(/&/g, '%26')+'&sub='+sub.replace(/&/g, '%26')+'&minor='+minor);

to

    pl_si.sack.runAJAX('call=save_page&range='+range+'&page='+page+'&text='+encodeURIComponent(text)+'&sub='+encodeURIComponent(sub)+'&minor='+minor);

Do you foresee any problems with that? Thanks. — Rik BlokRik Blok
rikblok

2011/11/05 07:51





Hello, I tried to implement inlineeditor in Dokuwiki Angua but I cannot find the text to be changed in “linkwiz.js”. Anyway without the changes I cannot get it working in this release. Chris Nelis 20120216


Hi, same for me too nothing to change in .js and doesn't do anything at all. Julian Knight, 2012-03-06

Even worse, it uses old code (from quickedit?) that is DEPRECATED and so triggers lots of warning messages - I've stopped using it. Instead I've implemented a quick and dirty jQuery hack:

jQuery(function(){
  jQuery('#bodyContent').dblclick(function() {
    window.location = '?do=edit';
  });
});

This seems to work well enough for me though you should not double-click when the editor is already open as it will reopen losing your changes (you do at least get a warning).

Julian Knight 2012-03-15

=== Hi,

Yes. The inlineeditor doesn't work in the new dokuwiki version. I don't have time to update the plugin at the moment. Anybody who would like to help are very welcome! @Julian, I like your suggestion, but it does not solve the basic issue the inline tries to solve; namely that when you hit the back button after editing you end up in the editor window (not as you should the previous wiki page). Simon-Shlomo Poil 2012-05-18

Messes with Meta data

Cautionary note: this plugin will cause the meta data, specifically the description in the meta data, to be filled with HTML with embedded Javascript in it on every page you modify. The resulting mess is something I'm still trying to clean up.

I only just found about this problem when I was trying to display the “desc” column using the plugin “dir” and it was breaking the page because it just dumps whatever is in the meta field “description” into the listing and all the DIVs and javascript causes a meltdown. -fumigatorRandy Whitaker
fumigator

8/30/2011

plugin/inlineeditor.txt · Last modified: 2015-07-23 15:30 by zioth