Jump to content

Talk:VisualEditor/2022

Add topic
From mediawiki.org
Latest comment: 3 years ago by Ti infotrad in topic Migrating extension to new version

Previous discussion was archived at Talk:VisualEditor/Archive 1 on 1 September 2015.

Adding button to apply smallcaps template to selected text

[edit]

Hello. I am trying to add a button to Visual Editor, to apply smallcaps template to selected text. So far, I have been able to create the button, following the example at VisualEditor/Gadgets/Add a tool. Now I can insert some fixed text in smallcaps, with this code: var myTemplate = [ {

type: 'mwTransclusionBlock',
attributes: {
 mw: {
  parts: [ {
   template: {
    target: {
     href: 'Template:Smallcaps',
     wt: 'Smallcaps'
    },
    params: {
     1: {
      wt: 'my parameter'
     }
    }
   }
  } ]
 }
}

}, {

type: '/mwTransclusionBlock' 


} ];
And then assigning it to a toolbar button, as described in VisualEditor/Gadgets/Add a tool. Now, the next step is replacing the fixed text 'my parameter', with the selected text from the editor. I have very little knowledge of Javascript, maybe this is a trivial issue but I don't know how to deal with it. Any help is much appreciated. 83.36.48.202 (talk) 21:55, 13 January 2022 (UTC)Reply

I know even less than you do about Javascript, but I wonder if w:en:User:Matma_Rex/nwe-nowiki.js would be a helpful model. It adds nowiki markup for me. Whatamidoing (WMF) (talk) 04:11, 14 January 2022 (UTC)Reply
@Whatamidoing (WMF) Thanks for your response. It seems like that method could also work for me, with small modifications. Could you tell me where and how are you inserting that code? I tried to insert it the same way as my previous code, but it didn't work for me. 83.36.48.202 (talk) 11:42, 20 January 2022 (UTC)Reply
I found the solution myself. This topic gives an example of exactly what I am trying to achieve, as a gadget: Talk:VisualEditor/Gadgets/Add a tool#h-How_to_wrap_selection_in_a_simple_template?-2020-01-26T21:11:00.000Z 83.46.41.89 (talk) 07:40, 24 January 2022 (UTC)Reply
Congratulations. I'm glad that you found that. Whatamidoing (WMF) (talk) 02:21, 25 January 2022 (UTC)Reply

VisualEditor button does not work

[edit]

Hello. I am working on a local mediawiki 1.37.1

At first when I added wfLoadExtension( 'VisualEditor' ); it was okay and i could edit some text

then the "Error contacting the Parsoid-/RESTBase-Server (HTTP 403)" started to appear and it stopped working.

And know when I click on the edit button, nothing happens. just the page refreshes and for a moment u could see the loading bar


WHat should I do?


mediawiki 1.37.1 is the last stable version and I do not intend to upgrade to 1.38 until it is stabe. Idris, the wise (talk) 12:20, 24 February 2022 (UTC)Reply

I suggest posting this at Project:Support desk. It sounds like you might be having a problem with site configuration. Whatamidoing (WMF) (talk) 21:09, 28 February 2022 (UTC)Reply

Tamplate shutdown my VisualEditor

[edit]

When I try to modify a page who contain a tamplate with the VisualEditor I have this error Error contacting the Parsoid/RESTBase server (HTTP 500) .

what should I do? Nicolas senechal (talk) 15:26, 11 March 2022 (UTC)Reply

Is this a private wiki, or one of the WMF-hosted wikis? Whatamidoing (WMF) (talk) 16:38, 22 March 2022 (UTC)Reply
it's a private wiki. Nicolas senechal (talk) 08:11, 23 March 2022 (UTC)Reply
You might have better luck asking at Project:Support desk, since the folks there know something about installing MediaWiki and its extensions. Whatamidoing (WMF) (talk) 18:44, 23 March 2022 (UTC)Reply

Is there a way to preserve textarea undo history when injecting/inserting characters into the edit textarea?

[edit]

I was just glancing at https://stackoverflow.com/questions/44471699/how-to-make-undo-work-in-an-html-textarea-after-setting-the-value and https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand#browser_compatibility shows that execCommand is supported by all major web browsers. I noticed on Wikipedia both in the edit area at top (Special Characters), as well as the additional ones on the bottom (dropdown menu for Insert, Wiki markup, Symbols, etc.), that undo states are lost when clicking on any of the characters to insert. Is there a way that future versions can fix this to preserve the undo history?


Note: I see that execCommand is "Deprecated: This feature is no longer recommended." but otherwise still I would like to see a way to insert characters that preserves undo history. Also see https://stackoverflow.com/a/70831583 Jasonkhanlar (talk) 18:39, 19 March 2022 (UTC)Reply

Do you know whether this is specific to Firefox? Whatamidoing (WMF) (talk) 16:40, 22 March 2022 (UTC)Reply
It is not specific to Mozilla Firefox. The issue affects Chrome/Chromium and Opera Jasonkhanlar (talk) 05:59, 24 March 2022 (UTC)Reply
So that's most editors. @ESanders (WMF), do you have any thoughts about how this could be done? Whatamidoing (WMF) (talk) 00:54, 25 March 2022 (UTC)Reply
What does this have to do with VE? ESanders (WMF) (talk) 01:00, 25 March 2022 (UTC)Reply
I assumed that "textarea" was "the area where the text is" (e.g., ContentEditable), but I don't know. Whatamidoing (WMF) (talk) 18:14, 25 March 2022 (UTC)Reply
I think @Jasonkhanlar is referring to <textarea> in the 2010 wikitext editor. That has known issues with the undo stack (T33780), and my go-to answer is to use the 2017 wikitext editor, which has it's own undo stack implementation. ESanders (WMF) (talk) 15:12, 28 March 2022 (UTC)Reply
I see. That is correct. It seems that https://en.wikipedia.org/ is using the 2010 wikitext editor, I tried to find the 2017 wikitext editor, and according to 2017 wikitext editor it is part of VisualEditor, which perhaps solves the undo state issue that I mentioned. Unfortunately, since neither Wikipedia seems to use it, nor does my webhost allow me to add "AllowEncodedSlashes NoDecode" to my website's VirtualHost section, and I get "Error contacting the Parsoid/RESTBase server (HTTP 404)" when enabling the VisualEditor extension for my site, I cannot check to see the 2017 wikitext editor in action. I read: https://mediawiki.org/wiki/Extension:VisualEditor#Allowing_VisualEditor_on_page_titles_containing_slashes Also whichever editor is used on Mediawiki.org, also undo does not work here either, when clicking the buttons to add special characters. Jasonkhanlar (talk) 00:22, 29 March 2022 (UTC)Reply
Your webhost may allow adding an .htaccess file? ESanders (WMF) (talk) 15:41, 29 March 2022 (UTC)Reply
Q: "Your webhost may allow adding an .htaccess file?"
A: https://httpd.apache.org/docs/2.4/mod/core.html#allowencodedslashes shows 2 contexts: server config or virtual host. There is no .htaccess context for the AllowEncodedSlashes Directive. Therefore, I am unable to enable encoded slashes from within a .htaccess file in my webhost environment. Jasonkhanlar (talk) 05:26, 30 March 2022 (UTC)Reply

adding tools to the standalone version

[edit]

How can I add or activate tools (extensions) like graph, math, and etc to the standalone version? Mabidan (talk) 06:39, 30 August 2022 (UTC)Reply

The stand-alone (non-MediaWiki) version of VisualEditor can be extended by writing code along the lines of VisualEditor/Gadgets#Triggering a command using a toolbar tool (though some of the advice there will not apply, because it's talking about the MediaWiki context).
The MediaWiki extensions you mention are each reliant on MediaWiki, and so can't be added to the stand-alone version of VisualEditor. Jdforrester (WMF) (talk) 12:36, 31 August 2022 (UTC)Reply

Enable Automatic citation in Nepali Wikipedia.

[edit]

Automatic citation is feature in most Wikis but not in Nepali Wiki. It would be a very handy new tool to have. Any ideas how you enable it? बडा काजी (talk) 18:02, 16 October 2022 (UTC)Reply

You need to configure your wiki to handle it: Citoid/Enabling Citoid on your wiki. This can be a little complicated, as it's built around the needs and processes of the bigger Wikipedias at the time, but should be do-able. Jdforrester (WMF) (talk) 13:22, 18 October 2022 (UTC)Reply

Migrating extension to new version

[edit]

I presently have a couple of extensions which are integrated with VisualEditor in MW 1.35. I am trying to migrate them to the new version (MW 1.39 RC1, downloaded zip) but I am getting a number of errors: non existing functions (template spec extend, onRawFallbackButtonClick, getParameterNames..). I have not been able to find documentation explaining how to migrate. Is there any available? Any help you can provide? I also could not find a list of extensions integrated in VE, which I could use to perform code comparisons. Ti infotrad (talk) 19:16, 21 November 2022 (UTC)Reply

And to be ultra precise, here is the error I am getting. Note I have not changed the code and it was working fine in my previous version of MW.
In my extension module, I have implemented the function insertTransclusionNode. In it, when inserting a new node, once I have build my object (getPlainObject), I call the following function
surfaceFragment.insertContent( [{type: 'gacdmslinker',attributes: {mw: obj,calaction: 'insert'}},{ type: '/gacdmslinker' }] );
and this is when I get the following error:
VM522:28 Uncaught TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'VeDmDocument'
    |     property 'bindings' -> object with constructor 'Object'
    |     property 'transact' -> object with constructor 'Array'
    |     ...
    |     property 'context' -> object with constructor 'VeDmInternalList'
    --- property 'document' closes the circle
    at JSON.stringify (<anonymous>)
    at ve.dm.Surface.storeChanges (load.php?lang=en&modules=ext.visualEditor.core%2Cmwtransclusion&skin=vector&version=1lvvz:180:941)
    at OO.EventEmitter.emit (<anonymous>:28:656)
    at ve.dm.Surface.breakpoint (load.php?lang=en&modules=ext.visualEditor.core%2Cmwtransclusion&skin=vector&version=1lvvz:175:902)
The weird thing is, my object (gacdmslinkernode) is still created in the sense that, if I save the document and re-edit it with VE, it shows up correcly. However, the error seems to be preventing the insertion of the title of the object (but not of the associated icon) and instead it uses the page title as the title. And also, when I update an existing node, I get no error and it works fine. Ti infotrad (talk) 01:08, 27 November 2022 (UTC)Reply

How to hook before "EDIT" in the visual editor?

[edit]

I'm studying to create my own extension with Visual Editor, and I'm struggling to figure out how I can make a hook in the dialog pop up for the contents.


For example, I'm making a traditional tag extension, like <ABC> MY TEXT </ABC>

And, When I enter the Visual Editor, the tag can be edit through the pop-up box, and the "Code" section shows "MY TEXT". This is good.


Now, before giving the text of "MY TEXT" to the "Code" section in the pop-up box, I want to manipulate the "MY TEXT" and give the manipulated string to the "Code" section.


For example, I want to give "_MANIPULATED_ MY TEXT _DONE_" to the "Code" section in the pop-up box in the Visual Editor instead of "MY TEXT" string.


Can someone help me how I can achieve the goal, please? 75.9.133.35 (talk) 19:46, 24 November 2022 (UTC)Reply