Skip to content

[3.0] Theme split (wave 1, part 6) — Repair the post preview - #9338

Merged
live627 merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/theme-preview
Aug 2, 2026
Merged

[3.0] Theme split (wave 1, part 6) — Repair the post preview#9338
live627 merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/theme-preview

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Wave 1, part 6 of breaking up #7933.

The preview does not work

On release-3.0, pressing Preview on a post does nothing at all — the preview section never appears — and the console shows two errors:

Uncaught ReferenceError: oEditorHandle_message is not defined
Uncaught TypeError: sceditor.instance(...).getText is not a function

Both are leftovers from the SCEditor upgrade.

oEditorHandle_<id> has not existed for a long time, but Post.template.php and Display.template.php still do

var oEditorObject = oEditorHandle_', Utils::$context['post_box_name'], ';

which throws, and takes the rest of that inline <script> block with it. quotedText.js was the only reader, using it to decide whether the editor was in rich text mode, so it now asks SCEditor directly. oEditorID is kept — quotedText.js and smf_fileUpload.js both still use it.

getText() is gone from the bundled SCEditor, so smc_preview_post.doPreviewPost() died on the first field it tried to collect. val() replaces it. spellcheck.js called it in two places as well, so those go the same way.

Why not the plugin from #7933

#7933 replaces this with an xmlPreview SCEditor plugin. I did not port it, because it takes its form data once and keeps it:

this.signalReady = function () {
	opts.oSendData ??= new FormData(editor.opts.original.form);
	...
};
var preview = function (event) {
	sendXMLDocument(opts.sUrl, opts.oSendData, response);

oSendData is captured when the editor becomes ready and reused for every click after that, so the preview would show whatever the form held at page load rather than what was typed. Repairing the existing code is a much smaller change and keeps the behaviour people expect.

I also left the quoteFast plugin from that branch alone. Quoting works today, and that plugin finds the quote link by walking to el.children[iChildNum].firstElementChild — a fixed position in the quick-buttons list, which moves as soon as a button is hidden by permissions — and calls insertQuoteFast unconditionally, dropping the case where the quick reply is collapsed and the click should take you to the full post page instead. I confirmed that path still works on release-3.0 and did not want to regress it.

Testing

  • Post page: Preview now opens the section and shows the subject and the parsed body. Previewed twice in a row with different text each time, to be sure it sends the current content and not a snapshot — Body typed <strong>after</strong> page load. then Completely different second body.
  • Personal messages: preview renders the typed subject and body, markup included.
  • Topic page: no console errors, oEditorID still resolves, and the rich-text mode flag quotedText.js sends computes correctly.
  • Quoting from a topic still navigates to the full post page with the quote pre-filled when the quick reply is collapsed.
  • 108/108 unit tests pass.

Three getText(false) calls remain in ManageNews.template.php and PersonalMessage.template.php. They sit inside 'oEditorHandle_x' in window guards that are always false, so they are unreachable; they belong to the parts that cover those templates.

🤖 Generated with Claude Code

Previewing a post does nothing: the preview section never appears and the
console reports

	Uncaught ReferenceError: oEditorHandle_message is not defined
	Uncaught TypeError: sceditor.instance(...).getText is not a function

Two separate leftovers from the SCEditor upgrade.

oEditorHandle_<id> has not existed for some time, but the post and topic
templates still assign it to oEditorObject. That throws, which abandons the
rest of that inline script. Only quotedText.js ever read it, to decide whether
the editor was in rich text mode, so ask SCEditor directly instead. oEditorID
stays; quotedText.js and smf_fileUpload.js both still use it.

getText() is gone from the bundled SCEditor, so gathering the form data for
the preview died at the first field. val() is its replacement. spellcheck.js
called it too, so it goes the same way.

Wave 1, part 6 of breaking up SimpleMachines#7933.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@albertlast albertlast mentioned this pull request Aug 1, 2026
@jdarwood007 jdarwood007 added this to the 3.0 Alpha 5 milestone Aug 2, 2026
@live627
live627 merged commit 54b2686 into SimpleMachines:release-3.0 Aug 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants