Repository navigation
feat: add EditLine#unstable_insertVertex - #1757
Merged
Merged
Conversation
… drags Leaflet drops a polygon ring's closing duplicate, so inserting a copy of the neighbouring vertex across the ring's start lost a vertex (or the new one) while still firing the events. Throw a RangeError instead. The rotate helper's editor has no vertex markers, so return undefined there. Amp-Thread-ID: https://ampcode.com/threads/T-4f0176da-b9a1-4ad0-aeca-c1780876e0eb
…ction EditRectangle inherits the hook, but a Rectangle keeps its 4 corner markers, so an insert left a 5-vertex ring and returned a corner marker. Return undefined there and change nothing. Amp-Thread-ID: https://ampcode.com/threads/T-4f0176da-b9a1-4ad0-aeca-c1780876e0eb
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.
Adds
EditLine#unstable_insertVertex(indexPath, latlng)(hook 1) for Pro's add-vertex-on-click. It is for@geoman-iopackages and has no semver guarantee. EditPolygon inherits it; EditRectangle does too, but Pro doesn't call it there.indexPathis the path the new vertex will have:[0, 3]inserts before ring 0's vertex 3,[2]on a line before vertex 2, and the ring's length appends._initMarkers()(and snapping whensnappable). So it needs no middle marker and works withhideMiddleMarkers, where the fork's fallback of firing a middle marker's event failed._addMarker) fires, in the same order:pm:edit, thenpm:change, thenpm:vertexaddedwith the new indexPath, marker and latlng. It also sets_layerEdited, sopm:updatefollows on disable._insertVertex, which fires onlypm:vertexadded. The Pro port lists it as a user-visible difference.addVertexValidation, as in the fork.RangeError: a wrong ring, an index out of range, a non-integer, or a ring path on a polygon. On a polygon, a vertex that would close the ring also throws aRangeError, because Leaflet drops a closing duplicate. That is a vertex at the ring's end equal to its first vertex, or at index 0 equal to its last. The JSDoc says to call it outside a vertex drag.Tests: new
cypress/e2e/insertVertex.cy.ts, 3 tests:pm:updateon disable;hideMiddleMarkersand a line;Mutants: firing only
pm:vertexadded(the fork's events) fails 1 test, skipping the marker rebuild fails 2, and dropping the ring-closing throw or the rotate check each fails 1.test/types/unstable.mtscalls it on anEditLinefrom./unstable.Checks: build, typecheck, lint, unit 103/103. Full e2e (Electron): base 480/480 (807c4f6), PR 483/483 (+3) at 1fe3d48; 2c13f0c only fixes JSDoc wording.
Independent review (Opus 5.5): three findings at fc8019f (the ring-closing duplicate, rotate mode, and the drag note), all fixed and confirmed at 1fe3d48.