Better formula editor

Some formulas in Coda can become complex. As they become more complex they become less readable. I would like to see the ability to format formulas using line breaks, comments and tabs to increase readability. This is particularly important when trying to maintain someone formulas written by others.

Additionally formulas should be created and edited in a much more functional window that allows resizing.

Lastly formulas should be able to be locked or owned by the author so they are not inadvertently changed.

23 Likes

+1 on the ability to resize the formula editor… as big as we want it.

And to reposition it… wherever we want it.

And to decouple it from the UI, so that it doesn’t jump around so much trying to keep up with user scrolling.

And @Jeff_Wright’s other ideas. :+1:

6 Likes

Hi @Jeff_Wright,

I agree with all of your proposed suggestions. We do have newlines now, see: Formula Formatting - WE HAVE NEWLINES

Lloyd

1 Like

@Lloyd_Montgomery Am I missing something with this?

I am trying to generate an email from boilerplate text and fields within a document. I do this by Concatenation it all together and it gets ugly. I don’t seem to be able to use Shift+Enter in this as it immediately breaks the formula when I insert one.

1 Like

I’m not sure why the formula is breaking. If you post a minimalist example then perhaps I can investigate.

Lloyd

For emails, I’ve used a section of the document for canvas formulas of each piece of the email content. Then I can just pull those into the email button by name instead of creating an extremely long formula.

In this document, Email Newsletter Planning-Sending-Logging, the Email Code section under the Data folder shows where I create each piece separately.

This strategy made it easier for me to edit later on.

+1 desperately need a better formula editor.

My formulas are often getting extremely complex. Writing them in a current editor is very painful. Need the features of adult editors, such as auto-indents and disabling line wraps.

image

7 Likes

Just to add my voice to the choir of wanting more from the formula editor. The current 6 rows and about 66 characters is a too small of an area to manage complex formulas.

My ideal would be to allow support for

  • Larger area for formula (Envoke with the same short cut as expanding any cell ⌘ + ⇧ + E
  • Tabs and intendation (switch between one line and indented view - like pretty / ugly format)
  • Comments with standard // and /* */ syntax that coders are familiar with - this would allow explaining weird formula choices and help when coming back to remember why it was done as such. This would also allow to mark stuff as TODO within formula, if something needs to be fixed/improved later.

As the formula editor is quite small I tend to copy paste the formula to an editor and work on it there, but then I lose the lookup and formula suggestions and end up copy pasting back and forth.

6 Likes

+1 to this. It’s not hard for the Coda dev team to resize the window and its would make a big difference!

2 Likes

A +1 on this feature! Looking forward.

+1 from me too!

Cheers.

One more suggestion: All formulas to have optional name and description fields where you can describe the usage and logic behind the formula.

Then there could be a list of of formulas in the “Doc map”. Especially in a more complicated Doc it would make things more manageble.

1 Like

I think the formula’s have a ‘name’ - it’s the column name itself. So the formula name is Table.[Column]. You can further target a specific row by typing @ and then the value in the ‘Display’ column.

This is separate from when you write =formula() on the canvas where that can be a discrete formula which you can reference.

Being able to add a description or comments would be amazing - AND is a more technical than resizing the window (v2) :slight_smile:

You’re right in saying that formulas in column technically have a ‘name’ but it’s more the name of the column used when displaying the data and not the formula specifically, and I can’t see a list of formulas I have in columns.

I’ve noticed I tend to make quite a lot of logic inside the column formulas, and it’s hard to keep track of them.

I don’t know what is the best solution, but what I would like is a way to see what formulas I have created in columns. And more obvious way to see which columns have formulas - for example when writing a new formula and referencing the column. Maybe a different icon with columns with formula?

OK so one idea I have used is to have a ‘database’ folder in your doc where you keep the tables with all of the ‘hard coded’ (non-formula) columns, then have another table in a folder called ‘Formulas’ (I use ‘fx’) and in that one I reveal everything. You are right it would be nice if it was baked into the UI. Another thing you can do is slowly drag your cursor along the header row and the columns with formulas with show the f icon.

1 Like

+1 to this please :smile:

Would make a big difference to productivity

I was playing around with this more and actually got pretty good results overriding some CSS to expand the formula editor:

/* Allow a wider view */

.formula_builder--root--MsCMk97F {
  width: 800px;
}

/* Allow a bigger height - would be better to calc() this in relation to current y position, but this works as a simple solution */

.formula_editor--root--1bazHdJA {
  max-height: 100%;
}

/* Allow for a wider width for a different view (I don’t remember exactly why I created this) */

.canvas_formula--popover--jY_Gbymw {
	width: 800px;
}

Put these into your favorite browser extension to inject CSS, I was using Chrome extension “User JavaScript and CSS”

4 Likes

Thanks for the discovery, Jami!

Just one thing. I wouldn’t rely on those --MsCMk97F etc to stay forever as class name pieces. Those look like autogenerated (versioning?) suffixes that may change at any time.

Rather use *[class^=formula_builder--root] selector that means “class attribute starts with”.

1 Like

Thanks for the tip Paul, I didn’t think of using that kind of a selector.
You are right, the hashy names of classes as such are very likely to change.

I thought this would be a great hack, however the CSS didn’t work. I did some research and it turns out you need to wrap the class in “double quotes”:
[class^="formula_builder--root"]

That’s the CSS. However I have not been able to get any CSS overrides to work in Coda.
I tried:

div[class^=“formula_builder–root”],
div[class^="formula_editor–root],
div[class^=“canvas_formula–popover”]
{background-color: pink; width: 1800px;}

Using both of these extensions.
Live editor for CSS, Less & Sass - Magic CSS
User JavaScript & CSS Extension

It doesn’t work live on coda.io, but if I rapidly resize the window I can see the background green color. Not able to get the formula builder to resize.