How to save codes on VS Code Mac? - reactjs

I am using VS Code on a Mac to write ReactJS, however I find that I could not save my code. If I use command and s to save, then the JSX will be a mess, just like shown in the picture:
enter image description here
So how could I solve it? Thank you

I think your code is being saved, but that your code formatting is messing-up your code.
Hit the following combination : Shift+Command+P
This will open a menu on top. Inside that menu type Format Document With..., and select it. It will allow you to format your code with a different auto-format tool. Choose the one that is appropriate for your code i.e. Prettier.

Related

Vscode is changing the code I wrote after saving the file, why?

[enter image description here](https://i.stack.imgur.com/lON9e.png)
I'm writing code for a task in a react course and after the file is saved it simply changes what I wrote and a bunch of errors appear and o I don't know why. The first pic is what I wrote, and the second one what happened after I saved the file. Can someone tell me why this is happening?
This never happened to any other code I wrote before.
Your VS Code settings are probably set to run a linter (ESLint maybe?) when you save your file. You can check your settings in the VS Code workspace settings: https://code.visualstudio.com/docs/getstarted/settings. If you hover over the red squiggly lines it will hint at the errors in your code.
It's been awhile since I've worked in React, but I think you might need to wrap your return in a string literal (backticks: ``). You also might want to use Typescript or JSX with React.
You can also post a sample on Stackblitz https://stackblitz.com/ if you want more help.

How do i let a user insert a link in an input field with normal text?

I am using react.js
I'm trying to build a blog page.
there is a texterea tag to write a blog for the user.
now I want to add the function that allows users to add words that are linked.
so that when i show the text from that input words that are linked are clickable
enter image description here
like the blue words in wiki in the image above.
pardon my mistakes (1st question in StackOverflow)
I know about dangerouslysetinnerhtml. but not sure if it's the right way to do so. because then users can modify the code inside (i think). so what is the safe and right way to do so
Reading your case Markdown seems best option as it also supports links insertion. For rendering user entered markdown you may use library like React Markdown. For writing markdown textarea is fine as long as you write markdown syntax properly but you may want to consider libraries like React textarea markdown editor to make things easier.

Is it possible to output formated text in a text file?

I`m working at a little text editor. My application is a winapi one in C. The idea is to write text in a large textbox(like in notepad) and then when I press a button it will take all text into a buffer, format it after some rules and then put it in a .txt file.
For example, if my input is:
Anne \red(got) \blue(\bold(apples)) and \italic(\bold(snails!))
After I parse it, it`s possible to put it into a .txt file and after I open it to see it like this?
I want to thank everyone for their time. I got exactly what answer I wanted. Everyone here rocks
I think that you are programming for fun, just for the pleasure of it, and with the perspective of learning more. If that is the objective, then it is okay to invent your own formats and essay your own solutions.
The problem presented can be twofold:
does the format results need to be shown in the editor itself?
or do you just need to do something that is going to be rendered in an external program?
If you are after the first possibility, then you need some Win32 (given your environment) component that will show the formatting. That component is RichEdit, and it implements RTF, a codification that can be saved to a text file, and which is more or less standard.
If you have the second possibility in mind, then you can choose from a variety of codifications. You would just be creating a text editor, probably with some helpers that write part of the commands for the user. For example, you could be creating a HTML editor, or a RTF editor.
There is a third possibility, though. You create your own codification, and when saving, you translate that codification to HTML, and then open the document in a web browser.
Say that you have:
\bold(hello), world.
You would translate that to:
<html><body><b>hello</b>, world.</body></html>
The possibilities, as you can see, are inifinite.
Hope this helps.

KDevelop: transform selected text?

I was wondering whether there was a function in KDevelop similar to the one that we used to have in Quanta (miss you, Quanta, btw).
I would like to set a keyboard shortcut, and apply a text transformation upon hitting it. Example:
I select my text to be translated, and I get back: <?=_('my text to be translated'?>
As you can see, this saves me a lot of awkward keystrokes...
I only found this feature in PHPStorm (where it is called "Live Templates"). I defined it like this: <?=t('$SELECTION$')?> and I can call it by hitting CTRL+ALT+J, and select it from the dropdown that appears.
You should be able to do that using a snippet with the following text: <?=_('%{selection}'?>
And you can bind a Shortcut to a snippet.
However my tests showed that this doesn't work correctly - there seems to be a bug somewhere.
As alternative you can write a script that does insert the text. See the documentation.

DotNetNuke parse HTML before display

Could anyone tell me if there's some way of "hooking in" to DotNetNuke so that I can, for example, search and replace text for ALL HTML modules on the site?
e.g. if I use an HTML editor and enter the text {{replace_me}}, then I could have some code that detects "{{replace_me}}" every time a page is rendered and replace it with something else.
Please note that this is a simple example - there may be other ways of "replacing" text - however the actual use case we have is very specific and there will be some significant processing to decide what to replace :) - so whatever solution we implement should basically be:
Get HTML from DB -> Process it however we wish in full C# -> Deliver the modified string.
Thanks!
I believe you can do this with the use of an HTTPModule. Ifinity.com.au used to sell a module that did this, looks like you might be able to download it now for free (maybe?) at http://www.ifinity.com.au/Products/Inline_Link_Master/Product_Details

Resources