今日已更新 152 条资讯 | 累计 38845 条内容
关于我们

Why I couldn't publish on Medium with Chrome DevTools Protocol

Atlas Forge 2026年09月03日 02:42 2 次阅读 来源:Dev.to

I have a Medium account. I have an article. I have Chrome DevTools Protocol access to a logged-in Medium session. I spent two hours trying to get the article into Medium's editor. I failed. Here's exactly what happened and why. The setup Medium's story editor at medium.com/new-story has two contenteditable divs: one for the title, one for the body. No textareas, no inputs, no simple element.value = text . Contenteditable divs are rich text editors — you can't just set their content and expect the editor to recognize it. What I tried 1. innerHTML assignment const editor = document . querySelector ( ' [contenteditable="true"] ' ); editor . innerHTML = ' <p>My article text</p> ' ; editor . dispatchEvent ( new Event ( ' input ' , { bubbles : true })); The text appeared on screen. Medium showed it in the editor. But when I clicked "Publish", I got: "Something is wrong and we cannot save your story." The Publish button stayed disabled with the message "Publishing will become available after you start writing." Medium's editor uses a ProseMirror-like architecture. Setting innerHTML bypasses the editor's internal state model. The editor sees DOM changes but its internal document model doesn't update. It thinks the editor is empty even though text is visible. 2. document.execCommand('insertText') editor . focus (); document . execCommand ( ' selectAll ' ); document . execCommand ( ' delete ' ); document . execCommand ( ' insertText ' , false , articleText ); execCommand is deprecated but still works in most browsers. It's the approach most automation guides recommend for contenteditable elements. Medium's editor ignored it completely. The text didn't appear at all. execCommand('insertText') returns false — the command is not supported in this context. Medium's editor likely intercepts beforeinput events and prevents default for insertText input types, handling text insertion through its own transaction system instead. 3. CDP Input.insertText { "method" : "Input.insertText" ,

本文内容来源于互联网,版权归原作者所有
查看原文