Extension talk:CodeEditor

About this board

CodeEditor not working even here on MediaWiki.org?

5
Summary by Escalatr

Clearing user preferences enabled CodeEditor when logged in.

Escalatr (talkcontribs)

On my own MediaWiki 1.35 installation the CodeEditor extension does not work (downloaded the newest CodeEditor and WikiEditor packages).

Here, on MediaWiki.org all extensions are installed (Special:Version), same situation, CodeEditor not appearing if you try to edit CSS, JS or Module pages, like: https://www.mediawiki.org/w/index.php?title=MediaWiki:Vector.css&action=edit

If you check Wikipedia, CodeEditor is working there: https://en.wikipedia.org/w/index.php?title=MediaWiki:Common.css&action=edit One difference could be, VisualEditor is not enabled on Wikipedia in contrast to MediaWiki.org?

What is status of this extension, if it is not even working here, on the official site?

TheDJ (talkcontribs)

It's working just fine for me on mediawiki.org. What browser are you using ?

Escalatr (talkcontribs)

Using Chrome 106.x on Windows 10. New finding: the CodeEditor appears when I log out, but again not working while logged in. Now, I´ve reset my User Preferences bringing CodeEditor back to work(!).

Are there any settings/Gadgets colliding with the CodeEditor? As I still cannot figure out why it might not work on my own Wiki installation after updating.

TheDJ (talkcontribs)
Escalatr (talkcontribs)

CodeEditor magically reappeared on my Wiki installation, resetting User preferences and clearing the cache might have helped, not really obvious. Also there were no particular errors in debug console.

Thanks for the hints.

Custom booklets not shown

4
Summary by Cavila

Now documented and fixable in css or js.

Cavila (talkcontribs)

Hi, I added a custom booklet section to the WikiEditor toolbar. Unfortunately, when CodeEditor hides the default WikiEditor sections (advanced, characters and help), it additionally hides everything under the element with the "sections" class, which is exactly where WikiEditor has reserved space for booklet-related content (collapsed by default). Users can see the button on the toolbar, but the booklet itself remains hidden whatever you do. In order not to kill functionality, it seems best to be more discrete and just hide the specific booklets for the advanced, characters and help sections.

Cavila (talkcontribs)

I just noticed that someone else had bumped into what appears to be the same issue: https://phabricator.wikimedia.org/T284791

An easy css fix would be to replace `.codeEditor-ui-toolbar .sections` in in jquery.codeEditor.less with `.codeEditor-ui-toolbar .sections .section-advanced, .codeEditor-ui-toolbar .sections .section-characters, .codeEditor-ui-toolbar .sections .section-help`.

TheDJ (talkcontribs)

I don't see a particular reason why only those 3 should be hidden. There is a chance that implementing it like that would cause posts here with "why is it not hiding my custom booklet"... For whatever is written, someone might just as much expect the opposite.

You can of course always just locally override any CSS.

Cavila (talkcontribs)

I'm not sure why it should hide things like characters at all, but you're right that use cases differ from one wiki to another. Anyway, it's good to have this on record if anyone else bumps into the same issue (although I can't find the search feature for this issue board). Will close.

EveryNameIsUsed (talkcontribs)

Hi everybody,

i have installed the extension, but it only works, when editing.

This means, if i use "insert codeblock" the syntaxhighlighting and linenumber is shown correctly. After saving there is no syntaxhighlighting, the linenumbers are not displayed and the wikipage is categorised in "pages with syntax highlighting errors".


The only thing, that is written on the page is:

<syntaxhighlight lang="python3" line="1" start="55">

def quick_sort(arr):

   less = []

   pivot_list = []

   more = []

   if len(arr) <= 1:

       return arr

   else:

       pass        

</syntaxhighlight>

Jdforrester (WMF) (talkcontribs)

Hey there, this is the talk page for the "CodeEditor" extension that provides syntax highlighting for certain code pages when you edit, as you say.

The syntaxhighlight feature, which shows syntax-highlighted code blocks in wikitext pages, is provided by Extension:SyntaxHighlight.

EveryNameIsUsed (talkcontribs)

False positive syntax error

3
Anerisys (talkcontribs)

The syntax check indicates "Warning: Too many errors. (81% scanned)" on the following code. When removing one "test1();", no error is reported anymore.

// syntax check demo: false positive error
function test1(){ return true }

function test2(){
test1();test1();test1();test1();test1();test1();test1();test1();test1();test1();
test1();test1();test1();test1();test1();test1();test1();test1();test1();test1();
test1();test1();test1();test1();test1();test1();test1();test1();test1();test1();
test1();test1();test1();test1();test1();test1();test1();test1();test1();test1();
test1();test1();test1();test1();test1();test1();test1();test1();test1();test1();
test1();test1();test1();test1();test1();test1();test1();test1();test1();test1();
test1();test1();test1();test1();test1();test1();test1();test1();test1();test1();
test1();test1();test1();test1();test1();test1();test1();test1();test1();test1();
test1();test1();test1();test1();test1();test1();test1();test1();test1();test1();
test1();test1();test1();test1();test1();test1();test1();test1();test1();
}
Jdforrester (WMF) (talkcontribs)

Yes, jshint is pretty poor. T250315 is a proposal to replace it with eslint which has much better behaviour in general, and might (?) fix your problem here, but some people are concerned that switching will change which "false positives" (and new true positives) are flagged. Your input would be welcome if you think this would fix it or otherwise be a good move.

Anerisys (talkcontribs)

I tested it again and the error appears to have been repaired. No syntax error is reported, even if I add multiple times as many test1(); as before. Thanks much!

Reply to "False positive syntax error"

"unset" causes a warning in the CSS editor

1
Summary by Anerisys

Looks like the reason for this is browser compatibility.

Anerisys (talkcontribs)

For example, width: unset; and border: unset; cause a warning that reads "Expected … but found 'unset' ".

It is no major issue, since it does not refuse saving it, but the false error still needs to be removed at some point.

How to enable Lua syntax checks?

8
Xxmarijnw (talkcontribs)

On mediawiki.org, invalid Lua code is highlighted using a red squiggle. This does not seem to be enabled by default, and I can't figure out how to enable it on my wiki. How do I enable syntax checks for Lua code?

Sokote zaman (talkcontribs)
Xxmarijnw (talkcontribs)

That is not helpful. I obviously have Scribunto installed and working, but I do not get any syntax checks. Entering invalid Lua code reports no errors in the CodeEditor window.

Sokote zaman (talkcontribs)

Installing lua alone is not enough. You must also configure its engine. Both methods come in the Extension installation guide

Xxmarijnw (talkcontribs)

My Scribunto installation works, and I have configured LuaSandbox. Invoking modules works fine, but error reporting in the CodeEditor does not.

Sokote zaman (talkcontribs)

Can you find a page called Scribunto Can you create a page called Module:HelloWorld?

Xxmarijnw (talkcontribs)

I have already made and used a number of modules. They work fine.

Sokote zaman (talkcontribs)
Reply to "How to enable Lua syntax checks?"
Nicolas senechal (talkcontribs)

Hello, I don't know why but my codeEditor disappeared from visualEditor and wikiEditor, maybe because I put other extensions. So here is my list of extensions (from localSettings).

wfLoadExtension( 'AdvancedSearch' );

wfLoadExtension( 'ApprovedRevs' );

wfLoadExtension( 'BetaFeatures' );

wfLoadExtension( 'CirrusSearch' );

wfLoadExtension( 'CodeEditor' );

$wgDefaultUserOptions['usebetatoolbar'] = 1;

$wgScribuntoUseCodeEditor = false;

wfLoadExtension( 'CodeMirror' );

wfLoadExtension( 'DeleteBatch' );

wfLoadExtension( 'Echo' );

wfLoadExtension( 'Elastica' );

wfLoadExtension( 'Gadgets' );

wfLoadExtension( 'Highlightjs_Integration-master' );

wfLoadExtension( 'mediawiki-extensions-Cargo-3.0' );

wfLoadExtension( 'MultimediaViewer' );

wfLoadExtension( 'SandboxLink' );

wfLoadExtension( 'Scribunto' );

wfLoadExtension( 'TemplateData' );

wfLoadExtension( 'TemplateSandbox' );

wfLoadExtension( 'TemplateStyles' );

wfLoadExtension( 'TemplateWizard' );

wfLoadExtension( 'VisualEditor' );

wfLoadExtension( 'WikiEditor' );

Any help are appreciated.

TheDJ (talkcontribs)
Nicolas senechal (talkcontribs)

It's weird I don't have any error, but I have some last testing that I did. It's just like it's not displayed.

185.148.164.137 (talkcontribs)

I try with the minimum configuration so it can't be the configuration and I look again errors I don't have an error, I don't know how to fix it...

Any help is appreciated.


Nicolas Senechal

Nicolas senechal (talkcontribs)

I check with another php version, with the same configuration it don't work...


very strange because when I start it work so I realy don't know...

Reply to "Code editor and visualEditor"

Documentation Update & additional Namespaces

2
DesignerThan (talkcontribs)

Hello,

maybe someone with knowledge of this extension can update the Documentation? As I had to find out, the config Variables have no effect anymore. That would be great. Also it would be nice to have an option, to add additional namespaces where the extension should work i. e. Templates ...

DesignerThan (talkcontribs)

I got it working in the Template Namespace. The problem was, that the content model was on "wikitext". That is changeable over the Pageinformation link in the tools. There the content model needs to be changed to "Sanitized CSS", this option is only available if the Extension is activated.

Reply to "Documentation Update & additional Namespaces"

How to get the code editor on regular pages?

2
Summary by Kghbln

Works as expected: "Provides a syntax-highlighting code editor for site & user JS, CSS and Lua pages" // No code editor on regular wiki pages, i.e. wiki pages with the "wikitext" content model.

Kghbln (talkcontribs)

I have the following configuration:

wfLoadExtension( 'CodeEditor' );
wfLoadExtension( 'WikiEditor' );
$wgDefaultUserOptions['usebetatoolbar'] = 1;

I get the code editor on pages with a content model out of the box if it is e.g. "json", "css" etc. How do I get this code editor on pages with the content model "wikitext"?

From the very basic docu I understand that I should get some extra button for the wiki editor however I cannot find it.

Not sure what to do. A hint is appreciated. Thanks.

I am on MW 1.31.x

Kghbln (talkcontribs)

Ok, I guess I can self answer: "Provides a syntax-highlighting code editor for site & user JS, CSS and Lua pages".

Rail01 (talkcontribs)

Hey!

I recently found out that Ace editor has settings menu available under ctrl + , keyboard shortcut where users can switch between editor themes available by default and other options, but none of these is then preserved neither as a preference or at least in browser storage.

Can this be changed? Or at least can you tell me whether it's possible to alter these settings using JavaScript?

Thank you.


Small update: I managed how to alter some Ace session settings with codeEditor.config hook, but this isn't really a solution. Session instance only handles some basic settings such as tab size and whether to wrap text what is useful but doesn't replace actual extension's support for Ace settings manager.

Second update: I figured it out

Reply to "Settings preservation"