Skip to content

Single draw plugin - #422

Merged
dannyleech merged 98 commits into
mainfrom
single-draw-plugin
Aug 5, 2026
Merged

Single draw plugin#422
dannyleech merged 98 commits into
mainfrom
single-draw-plugin

Conversation

@dannyleech

@dannyleech dannyleech commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

The unified plugins/draw package replaces the separate draw-ml and draw-ol betas with a single plugin built on a shared adapter mechanism (MapLibre and OpenLayers implementations behind one interface), mirroring the pattern already used by the datasets plugin — draw-es remains a separate, unaffected plugin. It consolidates the drawing/editing API into a consistent set of methods (newPolygon, newLine, editFeature, addFeature, deleteFeature) and adds two new ones, split and merge, for turf-based polygon geometry operations. Validation is unified across both adapters via a shared built-in rule set (minimum vertices, self-intersection, non-zero area) plus an onGeometryChange callback contract with well-defined lifecycle phases, and shape/vertex/snap colours and sizes now resolve identically on both providers instead of being adapter-specific. It also wires in Move control D-pad support for nudging a selected vertex, brings substantial shared test coverage across both adapters, fixes a number of pre-existing bugs along the way (including a MapLibre edit-cancel regression that failed to revert a moved vertex), and adds full plugin documentation and an updated demo/docs example.

dannyleech and others added 30 commits July 1, 2026 21:24
…e shared utility

Moved touch target SVG generation out of individual adapters into a centralized utility
(/src/utils/touchTarget.js) that generates the SVG dynamically based on SIZES config.
Both adapters now import and use the same createTouchTarget, applyTouchTargetColors,
showTouchTarget, hideTouchTarget, and isOnTouchTarget functions.

This eliminates duplicate SVG strings and makes touch target sizing configuration-driven,
allowing coordinated changes across frameworks by updating SIZES.touchTargetSize or
SIZES.touchIndicatorRadius in a single location.

Changes:
- Created /src/utils/touchTarget.js with dynamic SVG generation
- Updated maplibre touchHandlers.js to use shared utility
- Updated openlayers touchTarget.js to re-export shared utility
- Fixed selector in mapboxDraw.js to use data-im-draw-touch-target

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
The function needs to be exported since mapboxDraw.js imports it.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Move hardcoded keyboard movement amounts (NUDGE=1, STEP=5 pixels) from individual
adapters to a centralized KEYBOARD config in defaults.js alongside COLORS, SIZES,
and TOLERANCES. Both MapLibre and OpenLayers now import from the same source,
ensuring consistent keyboard behavior across adapters.

This makes it easy to adjust keyboard movement sensitivity globally if needed,
and maintains consistency with the plugin's other configuration patterns.

Changes:
- Added KEYBOARD export to /src/defaults.js with nudgeAmount and stepAmount
- Updated maplibre/modes/editVertex/vertexOperations.js to use KEYBOARD config
- Updated openlayers/edit/keyboardHandler.js to use KEYBOARD config

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@dannyleech
dannyleech marked this pull request as ready for review August 5, 2026 12:48
@dannyleech
dannyleech merged commit 8b5e281 into main Aug 5, 2026
3 checks passed
@dannyleech
dannyleech deleted the single-draw-plugin branch August 5, 2026 13:07
@sonarqubecloud

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants