Turn off automatic space insertion on macOS - html

When you copy then paste the string “word”, macOS sometimes inserts “word” (unchanged), “ word”, “word ”, or “ word ”, depending on what you’re pasting it next to, whether it thinks you copied it as a word or as a range, and whether you’re pasting into a writing input (like a note in the Notes app) or a string input (like Safari’s URL bar). Click-and-dragging to select results in a range copy, double clicking results in a word copy.
On macOS, Safari and Chrome perform automatic space insertion in all inputs, while Firefox performs it in none. Firefox also does not follow the native behavior for double clicking a word, right clicking a word, or copying a word.
You can play with the behavior with the following demo. Try double clicking a word then pasting it multiple times, then try selecting a word by dragging then pasting it multiple times.
<div>one two three</div>
<input>
Automatic space insertion is probably fine and intuitive for macOS users, but is sometimes inappropriate for the same reason it’s inappropriate in Safari’s URL bar: some contexts are not in English or any other written language. In these contexts, automatic space insertion leads to surprising results. For example, I ran into this issue when entering input in a micro-language of the form [field.{id}], then pasting an ID, which was copied as a word, then getting [field. {id}] and the error that it caused.
Ideally, I want to instruct the browser not treat an input’s value as writing. Minimally, I want to turn off automatic space insertion an inputs. How can I do this?
Things I’ve tried that didn’t work:
Setting lang="" or lang="none" on both the input and the copied text
Setting lang="zh" on both the input and the copied text (Chinese languages do not use spaces between words)
Setting spellcheck="false" on the input
Setting autocorrect="off" on the input (non-standard, Safari only)

One solution is to cancel then mimic the paste event in JS.
<input id="example">
document.querySelector('#example').addEventListener('paste', e => {
e.preventDefault();
const pastedText = e.clipboardData.getData('text/plain');
document.execCommand('insertText', false, pastedText);
});
This solution has the following limitations:
Requires JS
Does not also disable other writing-specific niceties, if any exist
Uses the deprecated document.execCommand API

Related

Return key is not handled in cell editor

I'm studying mxGraph examples and have the following problem. When I double-click a cell and edit in-place its content, I assume that pressing Return key should end editing and set the cell's content to the newly typed. But instead pressing the Return key works as usually in editors: it moves the caret to the new line.
Why I assume that Return should stop editing? Because comments say so (e.g. in userobject.html):
// Stops editing on enter key, handles escape
new mxKeyHandler(graph);
And also because there would be no convenient way to end cell editing apart from clicking with the mouse somewhere outside the cell. (By the way, Escape key is handled OK: it also ends editing, but without updating the cell content.)
This behaviour is observed in all browsers I tried: Firefox 60 on Linux, Firefox 52 and IE 11 on Windows.
Why this problem exist and how can it be solved?
Have you tried graph.enterStopsCellEditing = true? See https://jgraph.github.io/mxgraph/docs/js-api/files/view/mxGraph-js.html#mxGraph.enterStopsCellEditing

When I create a new class="" the cursor starts outside the quotes in PhpStorm. How can I get it to go between the quotes so I can continue typing?

When I type in class="" it autofills and puts the cursor after the closing quote.
This means I need to delete a quote to enter the class name or click between them. Both of which ruin my workflow.
Is there a way to put the cursor inbetween the quotes in settings? And if there is, is there a way to jump out of the quotes and keep adding to my markup?
In Sublime Text it puts the cursor in the class and then tab takes you outside of it. I'm sure PhpStorm can do the same.
Instead of typing the whole class="" thing by yourself -- just let IDE autocompletion to do the job for you.
Just two characters (cl) is enough to make class entry first in the list (unless you have used some other similarly named attributes/properties recently that would temporarily bring them higher than class):
Completing with Enter will have the text inserted into current position with caret located in the right place class="[CARET_HERE]".
Completing with Tab does the same but replaces the text that is currently under caret (useful when changing class/image name/function/etc completely).
If standard code completion is not good enough for some reason or you do not like automatic completion popop (and prefer invoking it manually only when needed) -- you will be interested in Live Templates functionality that allows creating some abbreviation and expanding it into the final snippet with minimal key presses (e.g. cl[Tab] into class="|")
IDE also has options to:
insert quotes ("" or '') after typing = in XML/HTML attributes.
Settings/Preferences | Editor | General | Smart Keys --> Add quotes for attribute value on typing '=' and attribute completion
insert pair quotes (closing one) when entering opening one -- works in different contexts/languages. It will "eat" the closing quote preventing you from typing too many.
Settings/Preferences | Editor | General | Smart Keys --> Insert pair quote
In Sublime Text it puts the cursor in the class and then tab takes you outside of it. I'm sure PhpStorm can do the same.
If I understood you correctly (sorry, never used Sublime myself) -- No... and may not have it for quite some time (devs say that the way how IDE works somehow conflicts with proposed Tab or Esc behaviour).
Better explanation/arguments from both sides can be found in actual ticket: https://youtrack.jetbrains.com/issue/IDEABKL-6984

MS Access report to PDF cuts of some characters inconsistently

My print preview from MS Access shows everything perfectly fine. Here's the actual PDF file snapshot which shows some letters are cut in half. It happens inconsistently with this report and not always for the same data.
In this report only 5 out of 40 questions had their first letter cut in half.
Please advise.
I've tried adjusting where the data field must start, i.e. I've moved the start of the question a bit more right, but no difference.
Here's the design view I've highlighted in yellow where the question starts. I've moved it more right, makes no difference.
Here's where the user captures questions]
Your problem text lines have a stray Tab character (ASCII 9) at or near the beginning of the line, which is being interpreted as a lateral positioning move for the string. Your correct lines do not have a stray Tab. If you use Acrobat's text editor to delete the Tab, the rest of the line jumps properly into view.
Below, I've extracted the text of each line in your sample, and replaced the unexpected Tab character with an "X." If you use Acrobat text editing to navigate carefully to the spot in the line where the Tab is located (you won't see it directly, but it's there), Shift-cursor sideways to highlight the Tab alone, and delete it, you'll see the text revert to its normal appearance.
Note that the Tab is usually not the first character in the line, in lines where it appears:
SXources of polyunsaturated fats include
LXack of calcium is one of the major causes of osteoporosis
XDisaccharides are the simplest form of carbohydrate
Excessive long term protein intake may lead to kidney problems
Water soluble vitamins taken in excess have toxic effects in the body
LXack of calcium is one of the major causes of osteoporosis
SXources of polyunsaturated fats include
VXitamin B12 is involved in
I'm going to hazard a guess here that the problem was introduced in the text before it was uploaded to your final document, so that the unwanted Tabs somehow snuck in as body text. I hope that helps.
That is one weird effect. It is a bit suspicious that it only occurs towards the end of the document, but I have no idea what causes it.
Two workarounds worked for me:
1) Use
=" " & [Question]
as control source of the text box, and rename it to txtQuestion to avoid a circular reference. That's two spaces, one wasn't enough.
Move it a bit to the left, to make up for the increased indentation.
2) Don't use the Access-integrated PDF creator, use a PDF printer instead.
I used the Windows 10 integrated "Microsoft Print to PDF", but there are many free ones, e.g. https://en.pdf24.org/ (just google "pdf printer driver").
This created a larger .pdf file for me, but it doesn't show the error.
Edit: Interestingly, while Adobe Acrobat Reader shows the error, Foxit Reader or the Firefox integrated PDF viewer doesn't. Here is a single page example if anyone else wants to check.

Disable autocomplete on regular text input, but allow back>forward saving of value

I have an html input field, type text, that is not a password or any type of sensitive information. It is used frequently to put in dollar values. Autocomplete by a browser is annoying because it comes up every time, gets in the way (for some fields this system has its own autocomplete so that's crazy and I disable it there too, though not on this one). The field just requires typing in a dollar value which is different almost every time so autocomplete isn't very useful.
I used the autocomplete="off" on this field.
Then the users mentioned that now when they hit back in their browser, then forward, the value is cleared out. I traced it to this, that's indeed what it does. Other fields keep their values just fine as dictated by the browser's behavior.
Now how to I allow this saving of the value, but disallow the actual autocomplete? This change that came along with autocomplete is unwanted for me. I also don't see it mentioned at all on the w3schools page for autocomplete, but it does it in Firefox and Chrome.
Thanks for any suggestions. The simple thing would be to just allow autocomplete again so I might end up doing that :/
You could keep autocomplete off but create a local storage value that persists that particular fields last value, you could trigger when the value changes. When the page is loaded you would then have a function that checks to see if the value is in local storage and if so populate that field.
Here is an article on using local storage - http://www.thomashardy.me.uk/using-html5-localstorage-on-a-form

Sublime Search/Replace adds New Line

When I do a simple search/replace, without any regex, ST2 adds a newline to each replacement. What am I doing wrong?
Below, I want to change spaces to commas. It does so, but also throws in a newline.
If the text you would like to replace is somewhat limited in size, here is a workaround. It doesn't even incorporate the builtin replace feature, and it can be somewhat slow for large text files.
Hit CMD + F (or CTRL + F) to bring up the Find dialog on the bottom of the window. Enter whatever string you'd like into the text field. Click the "Find All" button, and you'll get multiple write positions into the file. You can write in two places at once! If you've done it correctly, you'll see not just one blinking vertical line (which usually indicates the position in the file that the read/write pointer is at), but multiple. You can then type as usual into the file, and it should add text in multiple places.