Fork me on GitHub
#hyperfiddle
<
2024-02-12
>
wei08:02:22

does anyone have a ui4-style contenteditable input i could borrow? i'd like a div whose text you can edit, and "input" triggers an e/fn with optimistic rendering

wei08:02:13

here's my first take, but it's unusable because the cursor gets reset to the start on every edit

#?(:cljs (defn inner-html [^js e] (.-target.innerHTML e)))

(defmacro content-editable [v V! & body]
  `(div (props {:content-editable true
                :contentEditable true})
     (control "input" inner-html identity ~v ~V! dom/set-val ~@body)
     (text ~v)))

henrik13:02:21

That’s normal with contentEditable. You need to reset the cursor position on every re-render.

henrik13:02:57

@ggaillard discovered something wonky in 689f5c44607d33897ccb213f887a9566e65f6f45:

base.js:650 Uncaught Error: Importing test-only code into non-debug environment: goog.testing.stacktrace
    at base.js:650:15
    at append.js:2:1
(anonymous) @ base.js:650
(anonymous) @ append.js:2
Points here:
goog.setTestOnly = function(opt_message) {
  if (goog.DISALLOW_TEST_ONLY_CODE) {
    opt_message = opt_message || '';
    throw new Error(
        'Importing test-only code into non-debug environment' +
        (opt_message ? ': ' + opt_message : '.'));
  }
};
This happens on advanced compilation only, as you might have guessed from the error. The commit just prior to this one works fine.

πŸ‘€ 1
henrik13:02:00

Unfortunately, the error is not more helpful than that. It just spits the entry point of the app (in append.js) and the Closure source location.

henrik13:02:49

I tried this on shadow 2.27.2 and 2.27.3.

Geoffrey Gaillard13:02:32

Thank you for the report. I think I know where to look at. Will keep you posted πŸ‘

πŸ‘Œ 1
henrik13:02:30

Not urgent or anything, I just discovered it when tracking master/configuring Jetty for the WSOD stuff.

henrik13:02:17

Btw, the Jetty 12 release from ring-jetty9-adapter has been updated with :ws-max-binary-message-size and :ws-max-frame-size, which means it now exposes the knobs needed to run Electric according to spec.

πŸ‘€ 3
Geoffrey Gaillard16:02:46

Fixed on 0cfb98429f0e9b4cb7822173d55d1498ce2dd972

πŸ™ 1
henrik07:02:39

Confirmed; it works fine.

Alan Carroll19:02:20

Eight months later I finally finished putting together a demo repo for combining electric with https://github.com/cjohansen/portfolio if anyone has interest https://github.com/alan-carroll/electric-portfolio

πŸ‘€ 9
πŸŽ† 4
πŸŽ‰ 3