# Changelog

All notable changes to the Insight Dezign Visual Editor plugin will be documented in this file.

## [1.1.0] - 2026-02-17

### Added
- Freemius SDK integration for licensing, updates, and analytics.
- `idve_is_pro()` helper function for gating premium features.
- Pro upgrade prompt on the settings page for free users (AI Assistant section).
- Freemius uninstall cleanup (removes options, global styles, and mu-plugin).

### Changed
- Settings menu renamed from "IDVE" to "ID Visual Editor".
- AI Assistant (settings, editor toolbar, REST endpoint) is now a Pro feature.
- AI JS script only enqueued for Pro users.
- AI REST endpoint returns 403 for free users.

## [1.0.1] - 2026-02-15

### Fixed
- Added translators comments for sprintf placeholders in AI error messages and core export notice.
- Replaced `strip_tags()` with `wp_strip_all_tags()` in HTML importer.
- Added phpcs:ignore for intentional `error_log()` calls in AI provider class.
- Added phpcs:ignore for external Font Awesome CDN (required for icon block editor).
- Added phpcs:ignore for inline style registration without version parameter.
- Added phpcs:disable for non-prefixed variables in uninstall.php.
- Added phpcs:ignore for direct database queries and slow meta_key in uninstall.php.
- Fixed readme.txt plugin name to match plugin header ("ID Visual Editor").
- Updated Tested up to 6.9.

## [0.1.20] - 2026-02-09

### Added
- Icon block — place FontAwesome 6 icons with configurable size, color, alignment, and optional link
- Icon picker: searchable grid of ~250 curated FA6 Free icons (solid, regular, brands) with manual class input for any FA icon
- Frontend persistence mu-plugin (`mu-plugins/idve-frontend-persist.php`) — auto-created on activation, loads FontAwesome 6 CDN and global stylesheet even when IDVE is deactivated
- FontAwesome 6 Free CDN enqueued in admin editor for icon block previews
- Icon block added to AI system prompt with FA class format documentation

### Changed
- Global Styles Export no longer shows a PHP snippet — the mu-plugin handles persistence automatically
- Deactivation warning updated to mention the mu-plugin for FontAwesome and global styles

## [0.1.19] - 2026-02-09

### Added
- AI "Refine Page" mode replaces "Edit Selected" in the toolbar AI modal — modify styles, text, layouts, or other properties across the existing page without regenerating from scratch
- AI Edit button on block settings modal footer — opens an inline prompt to modify the selected block with AI, then refreshes the settings panel with updated values

### Changed
- "Edit Selected" AI mode removed from toolbar modal (was unreachable — selecting a block opens settings modal which covers the toolbar)

### Fixed
- AI block editing is now accessible — prompt appears inside the settings modal where the block is already open, instead of requiring toolbar access while a modal is open

## [0.1.18] - 2026-02-08

### Added
- AI page/section generation can now create custom CSS classes alongside the page tree — enables box-shadows, gradients, hover effects, and other advanced styling automatically
- Expanded AI design guidance: system prompt now teaches stretch usage, creative CSS class generation, and improved layout practices
- Advanced tab for rows and columns — CSS Class and CSS ID fields now available on all element types

### Changed
- Block cssClass no longer duplicated on wrapper div for button and image blocks — class is applied only to the inner element (`<a>`/`<img>`) where styles are rendered
- AI system prompt comprehensively updated with full feature documentation (equal height rows, column gap, vertical alignment, background images, group blocks, cssClass rendering behavior) and modern design guidance (card layouts, drop shadows, gradients, hover transitions, typography)
- Stretch (Full Width / Stretch Background Only) moved from row settings to section settings — sections are now the full-width container, which aligns with how backgrounds and padding naturally apply
- Auto-migration: existing pages with stretched rows are automatically migrated on load
- Element identity refactored from HTML `id` attribute to `data-idve-id` — frees the `id` attribute exclusively for user-set CSS IDs and simplifies the importer

### Fixed
- AI-generated pages could have duplicate element IDs when the model reused IDs across sections, causing settings to apply to the wrong element — tree validation now deduplicates all IDs
- AI-generated CSS classes are now formatted with proper indentation before being appended to the global stylesheet

### Removed
- Row settings no longer include stretch mode or content max width (moved to section)

## [0.1.17] - 2026-02-08

### Added
- AI Assistant integration: generate full pages, add sections, edit selected elements, and create CSS classes from natural language prompts
- New `class-idve-ai.php`: provider abstraction supporting OpenAI and Anthropic APIs with dynamic system prompt, response parsing, and tree auto-repair/validation
- AI settings section on Settings > IDVE page with provider, API key, model, and custom instructions fields
- REST endpoint `POST /idve/v1/ai/generate` proxies AI requests server-side (API key never exposed to browser)
- New `admin/js/idve-ai.js`: toolbar button with purple gradient, modal UI with mode selector (Generate Page, Add Section, Edit Selected, Create CSS Class), loading spinner, and error display
- AI-generated content integrates with undo/redo history — Ctrl+Z restores previous state after any AI operation
- Generated CSS classes automatically appended to global stylesheet via existing API
- Comprehensive system prompt teaches AI the complete IDVE tree structure, all 10 block type schemas, design best practices, and available global CSS classes

## [0.1.16] - 2026-02-08

### Added
- Lossless import: "Import Current Content" now preserves all element settings (backgrounds, borders, padding, margin, stretch modes, etc.) from the original IDVE data when re-importing after external edits
- `preserve_or_generate_id()` helper: reuses existing element IDs from HTML `id` attributes instead of generating new ones on import, keeping `_idve_css` stylesheet selectors valid
- `build_settings_map()` / `apply_old_settings()` / `apply_old_block_settings()`: walk old and new trees to carry forward settings from `_idve_data` for matching element IDs
- `import()` now accepts optional `$old_tree` parameter for settings merge (backward compatible — null skips merge)
- REST API `load()` passes the stored `_idve_data` tree to the importer during `force_import` so settings survive re-import

### Changed
- Image block render now puts settings-level padding, margin, border, and background-color inline on the `<img>` element (matching the button block's `<a>` pattern) — settings are no longer CSS-only, making HTML self-contained for import

### Fixed
- Global Class Browser now only shows standalone classes (`.my-style { ... }`) and filters out compound selectors (`.my-style h2 { ... }`) so only directly-applicable classes appear in search results
- Image/button block settings (padding, border-radius) stored only in `_idve_css` are no longer lost on re-import — old tree settings are merged directly
- Image block importer now reads settings (padding, margin, background-color, border) from `<img>` inline styles instead of skipping them
- Background images on sections/rows/columns no longer lost when TinyMCE strips inline styles during external editing
- Column widths preserved from old tree instead of being re-parsed from CSS classes (which may lose precision)

## [0.1.15] - 2026-02-08

### Added
- Extensible Block Import API: external plugin blocks are now recognized during HTML import instead of falling back to generic HTML blocks
- `parse_block_type()` checks all registered block types (via `idve_register_blocks`) after the 10 core types
- Generic shortcode parser: automatically reverse-engineers `[$type attr="val"]` shortcodes from imported HTML, mapping attributes to registered field names with defaults
- Enclosing shortcode content (`[$type]content[/$type]`) mapped to `content`, `message`, or first textarea/richtext field
- `import` key in block registration: plugins can provide a custom import callback via `'import' => callable` in their `register()` call
- `idve_import_block_data` filter: plugins can intercept import parsing for any block type without registering an import callback
- Import priority chain: custom callback → filter → generic shortcode parser → HTML fallback
- `parse_row_settings()`: extracts row settings from HTML — stretch mode, equalHeight, gap, contentMaxWidth, background (color/image/size/position/repeat), padding, margin, border

### Fixed
- Importer now preserves row settings (stretch mode, equal height, column gap, content max width, backgrounds, padding, margin, borders) — previously rows were imported with no settings at all, losing all customization on re-import
- Section settings now fully preserved: background size/position/repeat and borders are extracted (previously only background color and image were parsed)
- Column settings now fully preserved: margin, borders, and background images are extracted (previously only padding, background color, and vertical alignment were parsed)

### Changed
- `IDVE_Importer` constructor now accepts `IDVE_Blocks` registry (passed from `IDVE_Core`)
- `parse_block_data()` dispatches non-core types through the extensible import chain instead of always falling back to HTML
- Default settings for sections, rows, and columns now include all fields (border, background size/position/repeat) matching the editor's full settings structure

## [0.1.14] - 2026-02-08

### Changed
- Importer now reverse-engineers all 10 block types from rendered HTML instead of falling back to generic HTML blocks
- `parse_block_type()` recognizes divider, audio, and group blocks (previously only text, heading, image, button, spacer, video, html)
- Block data extraction now parses inline styles for colors, font sizes, alignment, spacing, borders, and other properties per block type
- Section and column settings (padding, margin, background color, vertical alignment, background images, max-width) are now extracted from rendered HTML
- Block settings (padding, margin, background color, borders, visibility, CSS class, CSS ID) are now extracted from wrapper/inner element styles
- Group blocks are parsed recursively — child blocks inside groups are properly typed instead of lost
- Block query changed from XPath descendant search to direct-child-only traversal, preventing group children from being double-counted
- Button block settings (padding, margin, border) correctly extracted from inner `<a>` element where renderer places them
- Video block reverses YouTube/Vimeo embed URLs back to watch URLs
- Divider block reconstructs thickness, color, width, and alignment from `<hr>` inline styles
- Audio block extracts URL, boolean attributes (controls/loop/autoplay), preload, and caption from `<audio>`/`<figcaption>`

### Fixed
- "Keep IDVE Version" in drift detection now marks the editor dirty and shows the unsaved changes warning, so the user saves (regenerating `post_content` and updating the content hash) instead of the drift reappearing on every load
- "Back to Default Editor" now forces TinyMCE to re-render after un-hiding `#postdivrich` — TinyMCE's iframe was initializing at 0 dimensions while hidden, causing a blank/broken editor when switching back

### Added
- `parse_inline_style()` helper: parses CSS style strings into associative arrays
- `parse_spacing_style()` helper: parses CSS shorthand spacing values into IDVE spacing objects
- `parse_border_styles()` helper: parses per-side border CSS into IDVE border settings structure
- `parse_block_settings()`: extracts block-level settings from wrapper element attributes and styles
- `parse_section_settings()`: extracts section settings including background images and max-width from inner container
- `parse_column_settings()`: extracts column settings including vertical alignment from `align-self`/`justify-content`
- `parse_block_from_element()`: refactored block parsing into standalone method for recursive group support
- `query_direct_child_blocks()`: finds only immediate child blocks of a container element
- `extract_extra_classes()`: filters IDVE system classes from class strings to recover user CSS classes
- Per-type data parsers: `parse_text_data()`, `parse_heading_data()`, `parse_image_data()`, `parse_button_data()`, `parse_spacer_data()`, `parse_video_data()`, `parse_divider_data()`, `parse_audio_data()`, `parse_group_data()`

## [0.1.13] - 2026-02-08

### Added
- Drift detection: when `post_content` is modified outside IDVE (e.g., Classic Editor while plugin was deactivated), a warning modal appears on next editor load
- Modal offers two choices: "Keep IDVE Version" (use stored JSON tree) or "Import Current Content" (rebuild tree from current HTML)
- Content hash (`_idve_content_hash`) stored on every IDVE save to track external modifications
- `force_import` parameter on `GET idve/v1/load/{post_id}` endpoint to force tree rebuild from `post_content`
- Legacy pages without a stored hash gracefully skip drift detection

## [0.1.12] - 2026-02-08

### Added
- Global Stylesheet editor: toolbar button opens a CodeMirror-powered CSS editor modal for defining reusable classes across all pages
- Global styles saved to `idve_global_styles` option and written to `wp-content/uploads/idve-global-styles.css` physical file
- Global styles enqueued on all frontend pages (file-based with inline fallback)
- Class Browser: "Browse" button on CSS Class fields (section Advanced tab, block Advanced tab) opens a searchable modal listing all classes from the global stylesheet
- Class browser shows class name, property preview, and color swatch for color/background properties
- REST API endpoints: `GET/POST idve/v1/global-styles`, `GET idve/v1/global-classes`
- Global Styles Export section on Settings > IDVE page — exports CSS file and provides a PHP snippet for theme independence

### Changed
- CSS classes from the Advanced tab now propagate to the inner element (not just the wrapper div) for heading, text, button, image, divider, video, and audio blocks — global style classes like `.my-style { font-size: 44px }` now apply directly to the element

## [0.1.11] - 2026-02-08

### Added
- ID Post Grid: `button_color` shortcode attribute — custom color for category filter buttons, load more button, and read more button
- ID Post Grid: `button_style` shortcode attribute — square (default), rounded, or pill border-radius for all buttons
- ID Post Grid: `read_more_style` shortcode attribute — `text` (default plain link) or `button` (styled button matching button_color/button_style)
- All new options available in WPBakery (Style tab), IDVE editor, and standalone shortcode

## [0.1.10] - 2026-02-08

### Changed
- Renamed plugin from "Insight Dezign Visual Editor" to "ID Visual Editor"
- Editor toggle button now reads "Edit with ID Visual Editor" (and Gutenberg sidebar meta box updated to match)

### Fixed
- Collapsible sections now work — click handler was not matching the collapse button class
- Collapse toggle moved from left side to far right of section header (matching WordPress conventions)
- Frontend grid CSS and per-page inline styles now load based on whether the page has IDVE content (`_idve_css` or `_idve_data`), not whether the editor is currently active — layouts no longer break when switching back to the default editor

### Added
- `image_id` field type for settings panel — opens WP Media Library picker and stores the attachment ID with thumbnail preview
- IDSC card and testimonial blocks now use media library for image selection instead of manual ID entry
- ID Image Overlay block now uses media library for image selection
- Publish/Update button in the IDVE toolbar — saves IDVE changes first if dirty, then triggers the WordPress publish
- Unsaved changes warning banner in toolbar appears when edits are pending, reminding to save before updating
- ID Visual Editor logo icon in the left side of the toolbar

## [0.1.9] - 2026-02-08

### Added
- New standalone plugin: ID Image Overlay (`[id_image_overlay]` shortcode) — recreates VC Image Text Overlay without WPBakery dependency
- Image overlay supports 9 text positions, customizable text/background colors, opacity, font size, padding, and optional link
- ID Image Overlay IDVE integration: Image Overlay block with color pickers, opacity range slider, and live-styled preview

## [0.1.8] - 2026-02-08

### Added
- ID Team Members IDVE integration: Team Members block available in the IDVE block picker under "Shortcodes" category
- IDVE settings panel exposes all Team Members options (group, members per row, image style/shape, box style, visibility toggles)
- Editor preview shows a styled placeholder with groups icon and key settings summary

## [0.1.7] - 2026-02-08

### Added
- ID Post Grid IDVE integration: Post Grid block available in the IDVE block picker under "Shortcodes" category
- IDVE settings panel exposes all Post Grid options (template, columns, post type, visibility toggles, etc.)
- Editor preview shows a styled placeholder with grid icon and key settings summary
- Render function outputs `[id_post_grid]` shortcode with only non-default attributes

## [0.1.6] - 2026-02-08

### Added
- Collapsible sections: click the triangle toggle to collapse/expand a section's rows (UI-only, not saved)
- Delete columns: column headers now show a delete button on hover; deleting the last column in a row prompts to delete the entire row
- Add rows to existing sections: "+ Add Row" button inside each section opens a layout preset picker
- Image size selection: new "Image Size" dropdown on image blocks (full, large, medium_large, medium, thumbnail) resolved via `wp_get_attachment_image_src`
- Linked/unlinked spacing controls: margin, padding, border-width, and border-radius fields default to a single linked input with a chain-link toggle to expand to 4 individual inputs

### Changed
- Image block `imageId` field is now hidden from users and auto-populated when selecting/removing an image via the media picker
- History push moved into individual action cases in `handleAction()` so UI-only actions (collapse) don't create undo entries

### Removed
- `borderRadius` field from image block Content tab (redundant with border-radius in the Style tab's border controls)

## [0.1.5] - 2026-02-08

### Added
- Extension API: external plugins can register custom blocks via `idve_register_blocks` hook
- `idve_editor_scripts` action hook for external plugins to enqueue editor JS
- `IDVE.Blocks.setPreview()` JS API for setting block preview functions
- Auto-registration of PHP-registered blocks in the JS editor
- Block picker now groups blocks by category with headers
- `get_editor_config()` transforms PHP field format to JS-compatible format

## [0.1.4] - 2025-02-08

### Added
- Background image support for rows, columns, and group blocks
- Background size, position, and repeat controls for all elements with background images
- Section background images now have configurable size, position, and repeat (previously hardcoded to cover/center)
- Vertical alignment setting (top, center, bottom) for group blocks

### Changed
- Image block: padding, margin, border, border-radius, and background styles now apply to the `img` element instead of the wrapper div (matching button block pattern)
- Removed default 15px column gutters (padding-left/right on columns and negative margins on rows) — spacing is now fully user-controlled via settings
- Added `overflow: hidden` to columns to prevent content from spilling outside column bounds

## [0.1.3] - 2025-02-08

### Added
- Divider block with thickness, color, width, and alignment options
- Audio block with WP Media Library picker, controls, loop, autoplay, preload, and caption
- Group/Container block for wrapping blocks with shared background, border, or padding
- Block nesting support — blocks can be dragged into and out of Group blocks
- `renderAudioField` in settings panel for audio file selection

## [0.1.2] - 2025-02-08

### Added
- CSS-only tooltips with "?" icon on settings panel fields that need clarification
- Tooltip text for section fields: Max Width, CSS Class, CSS ID
- Tooltip text for row fields: Equal Height Columns, Column Gap, Stretch, Content Max Width
- Tooltip text for column field: Vertical Alignment
- Tooltip text for block advanced fields: CSS Class, CSS ID, Visible
- Tooltip text for block-specific fields: text color, font size, alt text, link target, max width, full width, video URL, aspect ratio
- `_tooltipHtml()` helper in settings panel for safe tooltip rendering
- `.idve-tooltip-trigger` / `.idve-tooltip-text` CSS styles with hover fade-in animation

## [0.1.1] - 2025-02-07

### Changed
- Replaced native `<input type="color">` with WordPress Iris color picker (`wp-color-picker`) for background color, text color, and block color fields
- Color picker now includes 8 preset palette swatches for quick color selection
- Modal close and refresh use jQuery cleanup to properly tear down Iris instances

### Added
- Lazy initialization for Iris pickers — pickers on hidden tabs initialize when the tab becomes visible, preventing width:0 rendering bugs
- `_pendingColorPickers` queue and `_initColorPickers()` method in settings panel
- Iris-specific CSS rules (`.idve-iris-field`) to fit the picker within the settings modal

### Unchanged
- Border color fields still use the native `<input type="color">` (compact inline layout)
- Opacity slider remains as a separate control below the Iris picker

## [0.1.0] - 2025-02-06

### Added
- Initial plugin build: visual row/column/block editor for WordPress
- Dual-store architecture: JSON in `_idve_data` (editor) + HTML in `post_content` (frontend)
- Per-page scoped CSS generation stored in `_idve_css` post meta
- 7 block types: heading, text, image, button, spacer, HTML, richtext
- Vanilla JS editor with no React, no build step, no shortcodes
- REST API (`idve/v1`) for save, load, autosave, import, and blocks
- Drag-and-drop reordering with HTML5 DnD API
- Undo/redo history system
- Rich text editing via `document.execCommand`
- Settings page (Settings > IDVE) for post type toggles
- Autosave to `_idve_autosave` post meta
- Revision support via `save_post` / `wp_restore_post_revision` hooks
- Row stretch modes: default, full width, stretch background only
- Column width presets and equal-height column option
- Border controls with per-side width, style, color, and radius
- Spacing controls (padding/margin) for all element types
- Background color and image support for sections, rows, columns, and blocks
- Gutenberg sidebar meta box for switching to IDVE
- Grid CSS preservation on plugin deactivation
- `wp_insert_post_data` filter to prevent WP Update from wiping IDVE content
