Mediawiki-wysiwyg / WYSIWYG-CKeditor

Mediawiki extension: WYSIWYG. Includes extension and other components required by it
GNU General Public License v3.0
67 stars 34 forks source link

Underscore added on some links #94

Open Varlin opened 7 years ago

Varlin commented 7 years ago

How to reproduce :

1) Take this sample in WYSIWYG view : "Lorem ipsum dolor sit amet" 2) Select "ipsum dolor" and click "Link" button 3) Type "ipsum dolor" and click ok 4) Don't do anything and validate 5) It has become "Lorem ipsum_dolor sit amet"

I'm pretty sur it has to do with "_fcknotitle" attribute but not sure if I can simply remove this from link/dialog.js with no harm...

riparap commented 7 years ago

Attribute _fcknotitle seems to cause it. It seems to be set only when new link is created but when existing link is edited that attribute is deleted, but I am not sure anymore if that fix is valid. _fcknotitle is used in mediawiki/plugin.js when html link is converted back to wikitext.

When fcknotitle is true, there should not be a separate title text for link. This seems to work otherwise, but when title of link is extracted for html it keeps original text of link as title text and this text contains "_" character instead of space. It may also be that attibute _fcknotitle is missing when it should be there ....I assume this is the problem behind this issue.

If _fcknotitle would be removed, I guess it will also work but means that in those cases where contents of link is the same as title text, you will always have both parts inside link. From mediawiki point of view plain link would do the same thing in this case.

riparap commented 7 years ago

Problem is not with attribute_fcknotitle directly. However, it seems that value of it is not always properly defined so that wikitext links without title texts will be converted to links with title text if page is opened and saved using wysiwyg.

Spaces inside internal link texts are converted to underscores in mediawiki/plugin.js when html => wikitext conversion is done. I remember that there has earlier been problems with spaces inside link names but I do not remember in what kind of situations (this has been prior to github repository), I suspect it was with external links. At that time fix for spaces to %20 with external links has not yet been there.

It seems that mediawiki is converting spaces inside page names to underscore anyway so I am just wondering if I could remove that change of spaces to underscores with internal links in plugin.js...

Varlin commented 7 years ago

Presently, fcknotitle attribute seems to be useless. Every single link which looks like "[[lorem]]" is transformed to "[[Lorem|lorem]]". (It is probably partially related to this change : https://github.com/Mediawiki-wysiwyg/WYSIWYG-CKeditor/blob/wysiwyg_mw127_459/WYSIWYG/CKeditorParser.body.php#L767 ) Ideally, we should find a way to avoid that, simply because the wikitext code would be cleaner.

But it seems complicated to me. So I just commented out line 187 in mediawiki/dialog/link.js It is sufficient to make the problem of this thread disappear.

jules-belanger commented 6 years ago

Any update on this ? Can't seem to be able to use Varlin's solution.