-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the enforce string option. Allow user to insert a number or a boolean value from the Insert context menu #104
Comments
The way to insert a text, number, or boolean is to click "Insert value" from the context menu. What you type as value determines what the type of the value will be, if you enter Is it that that icon of the "Insert value" button (a double quote) is misleading in this regard? |
Aha! Yes - that did make me assume it was inserting a string because of those quotes! I was trying to somehow convert an existing string value to a number without going into the code view and deleting the quotes. The Convert To menu has Object and Array as options - should it have String, Number, Boolean as well excluding from the options whatever type it currently is? |
Ok I'll see if I can come up with a better icon. Normally there is no need to specify the type explicitly, the editor detects the type itself and turns it into a number or boolean when needed. This conversion only works after you have edited the value though, it's not applied when loading a document. Does that working for you? (On a side note: in rare cases, you want to enter a string containing a numeric value, you can enforce to keep the value as string via the dropdown of "Edit value", and then select "Enforce string"). |
I discovered (by accident!) that clicking Edit Value->Enforce string on the pop-up menu when the current value is already a string representation of a number, will actually change the value a number (confirmed in the Code view). So that menu option is actually a toggle. I'm not sure if that's by design or a bug though? If it's by design then we need the menu text to say "Enforce number" when the value is a string representation of a number. Note: it works with floats as well, so "Enforce number" rather than "Enforce integer" if you want to go that way. |
Thanks for your input @brownieboy. I'm indeed not totally happy with how it works now, the feature is quite deep hidden away and a bit vague to understand. This menu item "Enforce string" is indeed a toggle, it has a toggle icon which is checked when the value is a string containing a numeric value, and unchecked when not. If you check it, the contents will be turned into a string. If you uncheck it (like you describe) it will be turned into a number if the contents are a numeric value. Thinking about a solution: maybe I can add a new entry to the list "Convert to: Structure | Object | Array | value". It can become a list "Structure | Object | Array | string | auto", and it should highlight the type that the value currently has. When selecting "string" it will keep the value always a string also when it contains a numeric value, and when selecting "auto", it will convert the value into whatever contents the value has, that can be: null, boolean, number, string. |
Yes, I'd totally missed the checkbox. So that makes sense now. Thanks for your quick response, @josdejong . |
Currently user can't insert a number (only a string) in tree mode - maybe add an option for Number to the context menu? Also boolean too.
The text was updated successfully, but these errors were encountered: