Feature Suggestion -- syntax highlighter #305

Closed
opened 2018-06-20 11:00:11 +00:00 by canfine · 22 comments
canfine commented 2018-06-20 11:00:11 +00:00 (Migrated from github.com)

This is a feature suggestion.

It could be very usefull feature to make new fieldtype with syntax highlight and implement it to the jcb custom scripting textarea

Expected result

https://highlightjs.org/
or some thing like that joomla

Actual result

just text area

Additional comments

jcb takes some of the ide's features to simplify component development. On the other hand, the lack of syntax highlighting complicates the work with it

### This is a feature suggestion. It could be very usefull feature to make new fieldtype with syntax highlight and implement it to the jcb custom scripting textarea ### Expected result https://highlightjs.org/ or some thing like that [joomla](https://extensions.joomla.org/extension/cedhighlightjs/) ### Actual result just text area ### Additional comments jcb takes some of the ide's features to simplify component development. On the other hand, the lack of syntax highlighting complicates the work with it
ro-ot commented 2018-06-20 11:31:03 +00:00 (Migrated from github.com)

This is a wonderful idea, and something we have also been talking about. We are also thinking about code hinting.

How much can you contribute to make this happen?

This is a wonderful idea, and something we have also been talking about. We are also thinking about code hinting. How much can you contribute to make this happen?
canfine commented 2018-06-20 13:02:19 +00:00 (Migrated from github.com)

@ro-ot, Sorry, I'm not a native speaker and I'm not an active github user. So I'm not sure I got you right. Explain in detail what is required of me?

@ro-ot, Sorry, I'm not a native speaker and I'm not an active github user. So I'm not sure I got you right. Explain in detail what is required of me?
ro-ot commented 2018-06-21 00:08:19 +00:00 (Migrated from github.com)

Ok, well I am simply asking, if you can help code this.

Ok, well I am simply asking, if you can help code this.
canfine commented 2018-06-22 07:07:08 +00:00 (Migrated from github.com)

Ok. I think that this task consists of three parts:

  1. input template and additonal options to field type
  2. embedding in the copy of the textarea fieldtype
  3. replacing the corresponding field types
    the first part I will provide
Ok. I think that this task consists of three parts: 1) input template and additonal options to field type 2) embedding in the copy of the textarea fieldtype 3) replacing the corresponding field types the first part I will provide
canfine commented 2018-06-22 07:31:23 +00:00 (Migrated from github.com)

Textarea doesn't fit.
need fieldtype "editor" with a non-default editor,
create an options of creating the field . In this option user shoud enter the installed editor like codemirror. and choose theme of highlight.

Textarea doesn't fit. need fieldtype "editor" with a non-default editor, create an options of creating the field . In this option user shoud enter the installed editor like codemirror. and choose theme of highlight.
canfine commented 2018-06-22 07:54:09 +00:00 (Migrated from github.com)

the easiest way to use instead of textarea field type editor field type and
plugin
and change the theme in codemirror plugin settings on the appearance options tab

the easiest way to use instead of textarea field type editor field type and [plugin](https://extensions.joomla.org/extensions/extension/authoring-a-content/admin-interface/switch-editor/) and change the theme in codemirror plugin settings on the appearance options tab
canfine commented 2018-06-22 08:13:18 +00:00 (Migrated from github.com)

the plugin is not even needed.
11
In the field options with the type "editor" there is an editor item

the plugin is not even needed. ![11](https://user-images.githubusercontent.com/5087049/41765610-4042330a-760d-11e8-8dc9-182e50e6fbb1.PNG) In the field options with the type "editor" there is an editor item
canfine commented 2018-06-22 08:14:38 +00:00 (Migrated from github.com)

that's all

that's all

The reason we did not go that direction is because the editors post via the site safety filters of Joomla and PHP is not allowed in most cases.

So what happens is, if you save a view/item that has php script in a field, or even JavaScript, the editor breaks it and often strips most of it away.

Have you been able to get it to work with PHP code snippets? I must admit I am speaking about four years ago, so it may have improved since. Just been to occupied to look, can you test this for us and give me some feedback? We are willing to change this, I mean why not... if it will work with PHP and JavaScript without stripping any code.

The reason we did not go that direction is because the editors post via the site safety filters of Joomla and PHP is not allowed in most cases. So what happens is, if you save a view/item that has php script in a field, or even JavaScript, the editor breaks it and often strips most of it away. Have you been able to get it to work with PHP code snippets? I must admit I am speaking about four years ago, so it may have improved since. Just been to occupied to look, can you test this for us and give me some feedback? We are willing to change this, I mean why not... if it will work with PHP and JavaScript without stripping any code.

Okay I just ran a test with a field in the admin view, and since the field is set as required it keeps saying that the field is empty. I then realized that it is due to the values being kept in the input field build by the editor, and so the form does not want to submit.

Any ideas how I can fix this? My JavaScript is not that great.

Okay I just ran a test with a field in the admin view, and since the field is set as required it keeps saying that the field is empty. I then realized that it is due to the values being kept in the input field build by the editor, and so the form does not want to submit. Any ideas how I can fix this? My JavaScript is not that great.
<field
	type="editor"
	name="javascript_view_file"
	label="COM_COMPONENTBUILDER_ADMIN_VIEW_JAVASCRIPT_VIEW_FILE_LABEL"
	description="COM_COMPONENTBUILDER_ADMIN_VIEW_JAVASCRIPT_VIEW_FILE_DESCRIPTION"
	cols="15"
	rows="30"
	buttons="false"
	editor="codemirror"
	filter="raw"
	required="true"
/>

This is the xml for the field that JCB builds, even if I remove the required field it gives the following error.
image

``` <field type="editor" name="javascript_view_file" label="COM_COMPONENTBUILDER_ADMIN_VIEW_JAVASCRIPT_VIEW_FILE_LABEL" description="COM_COMPONENTBUILDER_ADMIN_VIEW_JAVASCRIPT_VIEW_FILE_DESCRIPTION" cols="15" rows="30" buttons="false" editor="codemirror" filter="raw" required="true" /> ``` This is the xml for the field that JCB builds, even if I remove the required field it gives the following error. ![image](https://user-images.githubusercontent.com/5607939/41784822-ba14c974-7638-11e8-9f21-4af723051976.png)
canfine commented 2018-06-23 10:10:13 +00:00 (Migrated from github.com)

in com_templates " PHP " saving and highlighting works well. The keyword responsible for the correct display of " php " is " syntax" use search through folder.
222
2232

in com_templates " PHP " saving and highlighting works well. The keyword responsible for the correct display of " php " is " syntax" use search through folder. ![222](https://user-images.githubusercontent.com/5087049/41808495-de979e8a-76e6-11e8-9a58-35f155061b9d.PNG) ![2232](https://user-images.githubusercontent.com/5087049/41808505-149ae00a-76e7-11e8-894e-6f3b906746b3.PNG)
canfine commented 2018-06-23 10:18:20 +00:00 (Migrated from github.com)

And don't forget that some fields in JCB work with out "< ? php ?>". Plane changing their fieldtype would not work.

And don't forget that some fields in JCB work with out "< ? php ?>". Plane changing their fieldtype would not work.

Okay I have been able to get it to work, I am updating all the fields in the admin view that takes custom code. Then we can test...

Okay I have been able to get it to work, I am updating all the fields in the **admin view** that takes custom code. Then we can test...

Please test the converted fields that are now editor fields inside the admin view of JCB (staging branch)

Please test the converted fields that are now editor fields inside the admin view of JCB ([staging branch](https://github.com/vdm-io/Joomla-Component-Builder/archive/staging.zip))
canfine commented 2018-06-25 07:44:15 +00:00 (Migrated from github.com)

it's hard to test for me because I haven't used these fields until now
And now I meet with a mistakes, because I do not understand how they work yet.

PHP publish Method before
Target (array) $pks is an array of record primary keys and $value is the published state.

it will take some time to master these fields. Now I just can say that highlighting is worked.

it's hard to test for me because I haven't used these fields until now And now I meet with a mistakes, because I do not understand how they work yet. > PHP publish Method before > Target (array) $pks is an array of record primary keys and $value is the published state. it will take some time to master these fields. Now I just can say that highlighting is worked.
canfine commented 2018-06-25 07:50:34 +00:00 (Migrated from github.com)

Same fields in admin view were missed. 1,2) javascript footer and footers 3) Add Custom Import

Same fields in admin view were missed. 1,2) javascript footer and footers 3) Add Custom Import

Yes the idea is just to test that the field work, in submission/save of the view. Not in relation to its implementation to a component. Since that has not changed, does still work well.

The fields we have skipped are more complex and may take some time to convert. Specially all those related to the custom import option.

I will now start moving other areas to this implementation. I have learned to code without the editorial help of an editor, but this change is very welcome, and will make it much easier for others.

Yes the idea is just to test that the field work, in submission/save of the view. Not in relation to its implementation to a component. Since that has not changed, does still work well. The fields we have skipped are more complex and may take some time to convert. Specially all those related to the custom import option. I will now start moving other areas to this implementation. I have learned to code without the editorial help of an editor, but this change is very welcome, and will make it much easier for others.
ro-ot commented 2018-06-27 02:54:31 +00:00 (Migrated from github.com)

I have been running some tests and it seems like the editor is not always loading correctly, specially with areas that already has code.
The code does not show until you click in the box. So here I have a field with code, but it does not show.
image
So when I click in the editor it loads the code, but behind the line numbers.
image

This is with Joomla 3.8.10

I have been running some tests and it seems like the editor is not always loading correctly, specially with areas that already has code. The code does not show until you click in the box. So here I have a field with code, but it does not show. ![image](https://user-images.githubusercontent.com/2594383/41950247-1bd910de-79bd-11e8-9b82-2003d2a2edef.png) So when I click in the editor it loads the code, but behind the line numbers. ![image](https://user-images.githubusercontent.com/2594383/41950264-34cd53f2-79bd-11e8-8d9a-9a6df1c80646.png) This is with Joomla 3.8.10

Codemirror has become unstable with the last Joomla release. So I am pausing this feature request until further notice.

Codemirror has become unstable with the last Joomla release. So I am pausing this feature request until further notice.
canfine commented 2018-07-01 11:01:20 +00:00 (Migrated from github.com)

Сan you describe what is unstable? And give me a link to download and test version with codemirror, please?

Сan you describe what is unstable? And give me a link to download and test version with codemirror, please?

Well just download the latest JCB (staging branch) and try to save any code area that uses codemirror (Joomla default code editor) and you will see with the new Joomla 3.8.10 it does not work. I have been trying all kinds of validation, filters and yet it still continues to block the submission of the new custom code all over JCB.

I have tested this in other areas of Joomla, and it seems to work. But I can not find the problem ,already spend three days on this, so I am a little fed up.

Well just download the latest JCB (staging branch) and try to save any code area that uses codemirror (Joomla default code editor) and you will see with the new Joomla 3.8.10 it does not work. I have been trying all kinds of validation, filters and yet it still continues to block the submission of the new custom code all over JCB. I have tested this in other areas of Joomla, and it seems to work. But I can not find the problem ,already spend three days on this, so I am a little fed up.
Sign in to join this conversation.
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#305
No description provided.