Repository navigation
Parse shortcode attributes without creating DOM nodes; match names with digits (#11) - #13
Merged
Merged
Conversation
A shortcode selected as text when the dialog opens has its attributes read without creating any element in the CMS document: a handler attribute must never run and a src must never be fetched. Plus a regression guard that quoted, unquoted, entity and non-ASCII values and lower-cased names come out as before. Fails on the current code (ss5 and ss6): the handler runs. The parsing guard passes. Pair-programmed with my buddy Claude
getCurrentEditorSelectionAsParsedShortcodeData() read a selected shortcode's attributes by building it as an element with jQuery, which creates that element in the live CMS document. The attributes are now parsed in an inert document (document.implementation.createHTMLDocument), under a fixed tag name; values, entities and lower-cased names come out as before. placeholdersToShortcodes() rewrites the editor HTML in the same inert document instead of a live wrapper. dist rebuilt. Browser suite 48/48 on ss5 and ss6, including the new selection specs. Pair-programmed with my buddy Claude
[scb_year2] must stay [scb_year2] on save (not become [scb_year 2]), a registered name with a digit (h2_title) gets a placeholder, [button-large] does not match button, and a shortcode without attributes has no trailing space in its placeholder title. Fails on the current code (ss5 and ss6): [scb_year2] gets the scb_year placeholder, h2_title gets none, titles are "scb_year 2", "button -large" and "scb_year ". Pair-programmed with my buddy Claude
shortcodesToPlaceholders() now matches names as ShortcodeParser does, \w+ ending at whitespace or ']': /\[(\w+)(?:\s+([^\]]*))?\]/g. [year2] is no longer taken for [year] and saved back as [year 2], [button-large] no longer matches button, and a registered name with a digit gets its placeholder. A shortcode without attributes has no trailing space in its placeholder title and ?sc= any more ([year] rather than [year ]), so its default placeholder is one character narrower. dist rebuilt. The editor spec that expects title "scb_year " and a 157 px placeholder now fails on purpose; its expected values are updated in the next commit. Pair-programmed with my buddy Claude
) Deliberate behaviour change, decided in issue #11 (which named this spec): a shortcode without attributes is now "[scb_year]" in the placeholder, not "[scb_year ]". Expected title "scb_year" (was "scb_year ") and width 60 + floor(16 / 1.8 * 10) = 148 px (was 157 px for 11 characters). Nothing else in the spec changes. Suite 52/52 on ss5 and ss6. Pair-programmed with my buddy Claude
Pair-programmed with my buddy Claude
simpler 1.0.0 requires framework ^5 || ^6, so the ~0.2 || ^1 constraint resolves to 1.x on a fresh install or an update that includes simpler; ~0.2 only lets an existing 0.2/0.3 install stay. The README already says so. Pair-programmed with my buddy Claude
button.png and dialog.png are no longer used by the README, which has its own generated screenshots in docs/images. Only a commented-out rule in shortcodable.scss still names button.png; it is left as it is. Pair-programmed with my buddy Claude
Pair-programmed with my buddy Claude
The selection specs (added in this branch) selected with ControlOrMeta+A. On CI (Linux) Control+A selects the whole <p>, whose content does not start with '[', so nothing was parsed: the attribute spec failed and the probe spec passed without testing anything. The text node is now selected with TinyMCE's selection API, the probe spec first asserts the shortcode was parsed, and the handler and fetch probes are separate cases (one shortcode per selection; a second one only added junk attributes, so its src could never be fetched). Must-fail re-checked on the pre-fix client code (66aa785): both probe cases fail on ss5 and ss6 (handler ran; src fetched). With the fix: 54/54. Pair-programmed with my buddy Claude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Release 5.2.1.
placeholdersToShortcodes()uses the same inert document. Values, entities and lower-cased names come out as before (specs/selection.spec.ts).\w+ending at whitespace or](fixes Editor rewrites [name2] to [name 2] on save; names with digits get no placeholder #11,specs/names.spec.ts). Deliberate behaviour change: no trailing space in a no-attribute shortcode's placeholder title and?sc=; the editor spec's expected title and width are updated in their own commit, citing Editor rewrites [name2] to [name 2] on save; names with digits get no placeholder #11.composer.jsonlicence MIT (matcheslicense.md); UPGRADING corrected on which simpler a Silverstripe 5 install gets; unreferenceddocs/screens/*.pngremoved.Tests first, each failing on the old code (ss5 and ss6) before its fix. Local browser suite: 52/52 on ss5 and ss6.
Closes #11
Pair-programmed with my buddy Claude