-
Notifications
You must be signed in to change notification settings - Fork 93
Feature/print button #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Feature/print button #228
Conversation
WalkthroughAdds a new Gutenberg "weDocs - Print Button" block (editor UI, inspector, server renderer, styles, and built assets), converts frontend printing to an event-driven lifecycle, and renames internal locals in the bundled React JSX runtime in Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Nitpick comments (11)
src/blocks/PrintButton/Inspector.js (2)
114-137: Add rem to BoxControl unitsInclude rem for consistency with typography controls and theme scales.
<BoxControl label={__('Padding', 'wedocs')} values={padding} onChange={updateAttribute('padding')} units={[ { value: 'px', label: 'px', default: 0 }, { value: 'em', label: 'em', default: 0 }, + { value: 'rem', label: 'rem', default: 0 }, { value: '%', label: '%', default: 0 }, ]} /> <BoxControl label={__('Margin', 'wedocs')} values={margin} onChange={updateAttribute('margin')} units={[ { value: 'px', label: 'px', default: 0 }, { value: 'em', label: 'em', default: 0 }, + { value: 'rem', label: 'rem', default: 0 }, { value: '%', label: '%', default: 0 }, ]} />Also applies to: 121-125, 133-136
80-111: Consider modern color controlsPanelColorSettings is gradually being replaced by block supports “color” UI. Moving to supports-based colors would simplify code and improve theme palette integration.
Also applies to: 246-256
src/blocks/PrintButton/block.json (1)
11-14: Align support vs custom alignment attribute — pick oneYou declare supports.align and also a custom “alignment” attribute used by AlignmentToolbar. This duplicates UX. Either:
- Keep custom alignment and remove supports.align; or
- Use supports.align and drop the custom attribute, wiring useBlockProps to apply it.
"supports": { - "html": false, - "align": ["left", "center", "right"] + "html": false },Also applies to: 24-27
src/blocks/PrintButton/edit.js (1)
69-77: Add type='button' and missing style/size classes to previewPrevents accidental form submission; also reflect buttonStyle/buttonSize in the editor.
-<button - className={`wedocs-print-button layout-2 ${additionalClasses}`} +<button + type="button" + className={`wedocs-print-button layout-2 ${buttonSize}-size ${buttonStyle} ${additionalClasses}`} style={buttonInlineStyles} onClick={(e) => e.preventDefault()} > ... -<button - className={`wedocs-print-button layout-3 ${additionalClasses}`} +<button + type="button" + className={`wedocs-print-button layout-3 ${buttonSize}-size ${buttonStyle} ${additionalClasses}`} style={{ ...buttonInlineStyles, flexDirection: 'column', gap: '4px' }} onClick={(e) => e.preventDefault()} > ... -<button - className={`wedocs-print-button layout-1 ${additionalClasses}`} +<button + type="button" + className={`wedocs-print-button layout-1 ${buttonSize}-size ${buttonStyle} ${additionalClasses}`} style={buttonInlineStyles} onClick={(e) => e.preventDefault()} >Also applies to: 91-99, 115-123
assets/build/blocks/PrintButton/render.php (1)
125-165: Inline per-block CSS is acceptable; consider shifting static rules to CSS with varsKeep dynamic values as CSS variables on the element; move common rules to style.css to reduce inline bytes.
assets/js/frontend.js (2)
73-75: Handle popup blockers gracefully.If window.open is blocked/null, fall back instead of proceeding and throwing.
Apply this diff:
- const mywindow = window.open( '', 'my div', 'height=600,width=800' ); + const mywindow = window.open( '', 'my div', 'height=600,width=800' ); + if ( ! mywindow || mywindow.closed || typeof mywindow.closed === 'undefined' ) { + // Popup blocked; best-effort fallback + console.warn( 'weDocs: print popup was blocked, falling back to window.print().' ); + window.print(); + return false; + }
3-3: Nit: typo in variable name "anchestorItem".Prefer "ancestorItem" for clarity and consistency.
Apply this diff:
- const anchestorItem = document.querySelector( 'ul.doc-nav-list > li.page_item.current_page_ancestor' ); + const ancestorItem = document.querySelector( 'ul.doc-nav-list > li.page_item.current_page_ancestor' ); @@ - if ( ! anchestorItem?.classList.contains( 'wd-state-open' ) ) { - anchestorItem?.classList.add( 'wd-state-open' ); - anchestorItem?.classList.remove( 'wd-state-closed' ); + if ( ! ancestorItem?.classList.contains( 'wd-state-open' ) ) { + ancestorItem?.classList.add( 'wd-state-open' ); + ancestorItem?.classList.remove( 'wd-state-closed' ); }Also applies to: 420-423
src/blocks/PrintButton/render.php (3)
44-51: Don’t drop zero-values when merging spacing.empty('0') is true in PHP; users setting "0" would be lost. Use strict checks for ''/null.
Apply this diff:
-$padding = array_merge($padding_defaults, isset($attributes['padding']) ? array_filter($attributes['padding'], function($value) { - return !empty($value); -}) : []); +$padding = array_merge( + $padding_defaults, + isset($attributes['padding']) + ? array_filter($attributes['padding'], static function ($value) { + return $value !== '' && $value !== null; + }) + : [] +); @@ -$margin = array_merge($margin_defaults, isset($attributes['margin']) ? array_filter($attributes['margin'], function($value) { - return !empty($value); -}) : []); +$margin = array_merge( + $margin_defaults, + isset($attributes['margin']) + ? array_filter($attributes['margin'], static function ($value) { + return $value !== '' && $value !== null; + }) + : [] +);
21-22: Sanitize alignment to allowed values.Constrain to left|center|right to avoid unexpected CSS injection via arbitrary strings (even if escaped).
Apply this diff:
-$alignment = isset($attributes['alignment']) ? $attributes['alignment'] : 'left'; +$alignment = isset($attributes['alignment']) ? $attributes['alignment'] : 'left'; +$alignment = in_array($alignment, ['left','center','right'], true) ? $alignment : 'left';
83-93: Add ARIA role/label to the interactive link.Improve a11y by marking the anchor as a button and adding an aria-label.
Apply this diff:
- '<a href="#" id="%s" class="%s layout-2" title="%s"> + '<a href="#" id="%s" class="%s layout-2" title="%s" role="button" aria-label="%s"> @@ - esc_attr(__('Print this article', 'wedocs')), + esc_attr(__('Print this article', 'wedocs')), + esc_attr(__('Print this article', 'wedocs')),Repeat for layout3 and layout1:
- '<a href="#" id="%s" class="%s layout-3" title="%s"> + '<a href="#" id="%s" class="%s layout-3" title="%s" role="button" aria-label="%s"> @@ - esc_attr(__('Print this article', 'wedocs')), + esc_attr(__('Print this article', 'wedocs')), + esc_attr(__('Print this article', 'wedocs')),- '<a href="#" id="%s" class="%s layout-1" title="%s"> + '<a href="#" id="%s" class="%s layout-1" title="%s" role="button" aria-label="%s"> @@ - esc_attr(__('Print this article', 'wedocs')), + esc_attr(__('Print this article', 'wedocs')), + esc_attr(__('Print this article', 'wedocs')),Also applies to: 97-107, 111-121
wedocs.php (1)
173-174: Use add_filter for a filter hook.block_categories_all is a filter; using add_filter conveys intent and allows setting accepted args if needed.
Apply this diff:
- add_action('block_categories_all', [$this, 'register_block_category']); + add_filter('block_categories_all', [$this, 'register_block_category'], 10, 1);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
assets/build/block.js(1 hunks)assets/build/blocks/PrintButton/block.json(1 hunks)assets/build/blocks/PrintButton/render.php(1 hunks)assets/build/style-block.css(1 hunks)assets/js/frontend.js(1 hunks)src/blocks/PrintButton/Inspector.js(1 hunks)src/blocks/PrintButton/block.json(1 hunks)src/blocks/PrintButton/edit.js(1 hunks)src/blocks/PrintButton/index.js(1 hunks)src/blocks/PrintButton/render.php(1 hunks)src/blocks/PrintButton/style.scss(1 hunks)src/blocks/index.js(1 hunks)wedocs.php(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
src/blocks/PrintButton/edit.js (1)
src/blocks/PrintButton/Inspector.js (2)
attributes(16-29)Inspector(15-281)
src/blocks/PrintButton/render.php (2)
src/blocks/PrintButton/Inspector.js (1)
attributes(16-29)src/blocks/PrintButton/edit.js (1)
attributes(16-34)
assets/build/blocks/PrintButton/render.php (2)
src/blocks/PrintButton/Inspector.js (1)
attributes(16-29)src/blocks/PrintButton/edit.js (1)
attributes(16-34)
src/blocks/PrintButton/index.js (1)
src/blocks/PrintButton/edit.js (1)
Edit(13-193)
src/blocks/PrintButton/Inspector.js (2)
src/blocks/PrintButton/edit.js (1)
attributes(16-34)src/blocks/CustomControls/UnitControl.js (1)
UnitControl(4-27)
assets/build/block.js (1)
src/blocks/DocsGrid/edit.js (1)
wp(16-16)
🪛 Biome (2.1.2)
src/blocks/PrintButton/edit.js
[error] 77-77: Avoid passing content using the dangerouslySetInnerHTML prop.
Setting content using code can expose users to cross-site scripting (XSS) attacks
(lint/security/noDangerouslySetInnerHtml)
[error] 102-102: Avoid passing content using the dangerouslySetInnerHTML prop.
Setting content using code can expose users to cross-site scripting (XSS) attacks
(lint/security/noDangerouslySetInnerHtml)
[error] 123-123: Avoid passing content using the dangerouslySetInnerHTML prop.
Setting content using code can expose users to cross-site scripting (XSS) attacks
(lint/security/noDangerouslySetInnerHtml)
assets/build/block.js
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
assets/build/style-block.css
[error] 3-3: expected , but instead found (
Remove (
(parse)
[error] 3-3: expected , but instead found (
Remove (
(parse)
[error] 3-3: expected , but instead found (
Remove (
(parse)
[error] 3-3: expected , but instead found (
Remove (
(parse)
[error] 3-3: Unexpected unknown pseudo-class contains
See MDN web docs for more details.
(lint/correctness/noUnknownPseudoClass)
[error] 3-3: Unexpected unknown pseudo-class contains
See MDN web docs for more details.
(lint/correctness/noUnknownPseudoClass)
[error] 3-3: Unexpected unknown pseudo-class contains
See MDN web docs for more details.
(lint/correctness/noUnknownPseudoClass)
[error] 3-3: Unexpected unknown pseudo-class contains
See MDN web docs for more details.
(lint/correctness/noUnknownPseudoClass)
🔇 Additional comments (11)
src/blocks/PrintButton/Inspector.js (2)
31-45: updateAttribute helper looks solidMerges nested objects correctly and avoids accidental overwrites.
167-199: UnitControl API: units/onChange verified — confirm min WP/Gutenberg or add fallbackUnitControl accepts a units prop and related props; when given a unit-suffixed string (e.g., "12px") onChange returns that string including the unit — matches usage in src/blocks/PrintButton/Inspector.js (lines 167–199). Verify your repo’s minimum supported WordPress/Gutenberg version includes this API or add a fallback for older versions.
src/blocks/PrintButton/block.json (1)
1-107: Manifest looks consistent with Inspector/Edit/render attributesNo blocking issues spotted.
src/blocks/PrintButton/edit.js (1)
36-55: Button preview styles are comprehensiveGood use of CSS variables for hover colors and robust inline fallback.
assets/build/blocks/PrintButton/render.php (2)
11-16: Restricting to post_type 'docs' is fineGuards rendering on the front. Good.
84-121: href="#" can cause scroll-jumps without JSIf the print JS fails to bind, clicking will jump to top. Prefer a or ensure the JS cancels default reliably for .wedocs-print-article.
assets/build/blocks/PrintButton/block.json (1)
1-116: Ignore double-registration warning for PrintButton
The PrintButton block is only registered once in wedocs.php via assets/build/blocks/PrintButton; there’s no PHP registration pointing at src/blocks/PrintButton/block.json.Likely an incorrect or invalid review comment.
assets/build/block.js (1)
1-1: Bundled artifact: lint false-positives are expected.Minified/webpack output commonly triggers “used before declaration” lint warnings; source is fine.
Please rebuild after SCSS changes to keep this bundle in sync.
src/blocks/index.js (1)
3-3: LGTM — block registered in index.src/blocks/PrintButton/index.js (1)
6-8: LGTM — dynamic block registration uses metadata.name.Ensure block.json includes "render" so save returns null at runtime (it’s handled in PHP).
wedocs.php (1)
188-195: LGTM — PrintButton block registration with render callback.Server-side render is wired to the bundled path.
src/blocks/PrintButton/edit.js
Outdated
| <style dangerouslySetInnerHTML={{ | ||
| __html: ` | ||
| .wedocs-print-button:hover { | ||
| background-color: var(--hover-bg-color) !important; | ||
| color: var(--hover-text-color) !important; | ||
| } | ||
| ` | ||
| }} /> | ||
| </div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
🧩 Analysis chain
Remove dangerouslySetInnerHTML; move hover CSS to stylesheet using vars
Inline <style> with dangerouslySetInnerHTML triggers the linter and is unnecessary. Use a CSS rule that reads CSS variables already set on the element.
-<style dangerouslySetInnerHTML={{
- __html: `
- .wedocs-print-button:hover {
- background-color: var(--hover-bg-color) !important;
- color: var(--hover-text-color) !important;
- }
- `
-}} />Add to src/blocks/PrintButton/index.css (and build CSS):
.wedocs-print-button:hover {
background-color: var(--hover-bg-color) !important;
color: var(--hover-text-color) !important;
}
@media (prefers-reduced-motion: reduce) {
.wedocs-print-button { transition: none !important; }
}
Also applies to: 102-110, 123-131
🏁 Script executed:
#!/bin/bash
set -e
echo "PrintButton block files in src/blocks/PrintButton:"
find src/blocks/PrintButton -maxdepth 1 -type f
echo
echo "Search for inline <style> with dangerouslySetInnerHTML in edit.js:"
rg -n "dangerouslySetInnerHTML" -C3 src/blocks/PrintButton/edit.js || true
echo
echo "Check for existing index.css in PrintButton block:"
find src/blocks/PrintButton -maxdepth 1 -type f -name "index.css" || trueLength of output: 2378
Remove dangerouslySetInnerHTML; move hover CSS into src/blocks/PrintButton/style.scss
Delete the three inline <style dangerouslySetInnerHTML> blocks in src/blocks/PrintButton/edit.js (lines ~77–85, 102–110, 123–131). Add the rule below to src/blocks/PrintButton/style.scss and rebuild.
-<style dangerouslySetInnerHTML={{
- __html: `
- .wedocs-print-button:hover {
- background-color: var(--hover-bg-color) !important;
- color: var(--hover-text-color) !important;
- }
- `
-}} />Add to src/blocks/PrintButton/style.scss:
.wedocs-print-button:hover {
background-color: var(--hover-bg-color) !important;
color: var(--hover-text-color) !important;
}
@media (prefers-reduced-motion: reduce) {
.wedocs-print-button { transition: none !important; }
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <style dangerouslySetInnerHTML={{ | |
| __html: ` | |
| .wedocs-print-button:hover { | |
| background-color: var(--hover-bg-color) !important; | |
| color: var(--hover-text-color) !important; | |
| } | |
| ` | |
| }} /> | |
| </div> | |
| </div> |
🧰 Tools
🪛 Biome (2.1.2)
[error] 77-77: Avoid passing content using the dangerouslySetInnerHTML prop.
Setting content using code can expose users to cross-site scripting (XSS) attacks
(lint/security/noDangerouslySetInnerHtml)
🤖 Prompt for AI Agents
In src/blocks/PrintButton/edit.js around lines 77–85 (and also remove the
similar blocks at ~102–110 and ~123–131), delete the inline <style
dangerouslySetInnerHTML> blocks that inject hover and motion CSS; instead, add
the provided hover and prefers-reduced-motion rules to
src/blocks/PrintButton/style.scss and rebuild the project so the styles are
applied via the stylesheet rather than dangerouslySetInnerHTML.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
♻️ Duplicate comments (2)
assets/build/blocks/PrintButton/render.php (1)
43-51: Zero-preserving spacing merge: LGTM.Switch to filtering only null/'' correctly preserves "0" values. Thanks for addressing.
assets/build/style-block.css (1)
3-3: Invalid :contains() selectors removed: LGTM.The built CSS no longer includes :contains(); good.
🧹 Nitpick comments (7)
assets/js/frontend.js (2)
73-89: Handle popup blocking and missing article element before printing.If window.open is blocked or the button is placed outside an
, the code will throw or print an empty window.Apply:
- const mywindow = window.open( '', 'my div', 'height=600,width=800' ); + const mywindow = window.open( '', 'my div', 'height=600,width=800' ); + if ( ! mywindow ) { + console.warn( 'Print window blocked by the browser.' ); + return false; + } + const article = $( this ).closest( 'article' ); + if ( ! article.length ) { + console.warn( 'No article ancestor found for print button; aborting.' ); + try { mywindow.close(); } catch (e) {} + return false; + }
116-136: Detach load listener after firing (tiny hygiene).The window closes quickly, but remove the load listener after initiatePrint runs to avoid dangling refs in browsers that keep it alive.
- const initiatePrint = function() { + const initiatePrint = function() { + if (mywindow.removeEventListener) { + mywindow.removeEventListener('load', initiatePrint); + }assets/build/blocks/PrintButton/render.php (1)
81-122: Improve accessibility: add role and aria-label to the link “button”.The anchor behaves as a button. Add role="button" and an explicit aria-label. Optional: switch to , but anchor is fine if ARIA is set.
- '<a href="#" id="%s" class="%s layout-2" title="%s"> + '<a href="#" id="%s" class="%s layout-2" title="%s" role="button" aria-label="%s"> @@ - esc_attr(__('Print this article', 'wedocs')), + esc_attr(__('Print this article', 'wedocs')), + esc_attr(__('Print this article', 'wedocs')),Repeat the same additions for layout3 and layout1 anchors.
Also consider data attribute for targeting (non‑stylistic): data-wedocs-print-button="true".
src/blocks/PrintButton/edit.js (4)
63-78: Buttons should be type="button" and have aria-label.Prevents accidental form submission in nested contexts and improves a11y.
- <button + <button + type="button" className={`wedocs-print-button layout-2 ${additionalClasses}`} style={buttonInlineStyles} - onClick={(e) => e.preventDefault()} + aria-label={buttonText || __('Print', 'wedocs')} + onClick={(e) => e.preventDefault()} >
80-95: Apply same type/ARIA to layout3.- <button + <button + type="button" className={`wedocs-print-button layout-3 ${additionalClasses}`} style={{ ...buttonInlineStyles, flexDirection: 'column', gap: '4px' }} - onClick={(e) => e.preventDefault()} + aria-label={buttonText || __('Print', 'wedocs')} + onClick={(e) => e.preventDefault()} >
96-108: Apply same type/ARIA to layout1.- <button + <button + type="button" className={`wedocs-print-button layout-1 ${additionalClasses}`} style={buttonInlineStyles} - onClick={(e) => e.preventDefault()} + aria-label={buttonText || __('Print', 'wedocs')} + onClick={(e) => e.preventDefault()} >
36-55: Deduplicate inline SVG by extracting a PrintIcon component.Reduces repetition and keeps markup in one place.
+ const PrintIcon = () => ( + <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"> + <path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"/> + </svg> + );Then replace occurrences with {showIcon && }.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
assets/build/block.js(1 hunks)assets/build/blocks/PrintButton/render.php(1 hunks)assets/build/style-block.css(1 hunks)assets/js/frontend.js(1 hunks)src/blocks/PrintButton/edit.js(1 hunks)src/blocks/PrintButton/render.php(1 hunks)src/blocks/PrintButton/style.scss(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- src/blocks/PrintButton/style.scss
- src/blocks/PrintButton/render.php
🧰 Additional context used
🧬 Code graph analysis (2)
assets/build/blocks/PrintButton/render.php (2)
src/blocks/PrintButton/edit.js (1)
attributes(16-34)src/blocks/PrintButton/Inspector.js (1)
attributes(16-29)
src/blocks/PrintButton/edit.js (1)
src/blocks/PrintButton/Inspector.js (2)
attributes(16-29)Inspector(15-281)
🪛 Biome (2.1.2)
assets/build/block.js
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
🔇 Additional comments (4)
assets/js/frontend.js (1)
90-147: Event-driven print lifecycle: LGTM.afterprint + load wiring with a single-shot guard and fallback is solid.
Please sanity-check on Chrome, Firefox, Safari (macOS), and Edge (Windows) to confirm afterprint fires; fallback should not trip in normal paths.
src/blocks/PrintButton/edit.js (1)
112-168: Overall editor integration: LGTM.BlockControls, Inspector wiring, and style vars align with server render.
assets/build/block.js (2)
1-1: Exclude built assets from linters — no action required.
assets/build/** is already listed in .eslintignore and .biomeignore; no changes needed.
1-1: Remove stray console.log in editor code.console.log("editor panel:", r) remains in the built bundle.
Remove from source and rebuild:
assets/build/block.js
Outdated
| @@ -1 +1 @@ | |||
| (()=>{"use strict";var e,t={418:(e,t,o)=>{var l=o(609),a=Symbol.for("react.element"),r=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),n=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,o){var l,d={},s=null,c=null;for(l in void 0!==o&&(s=""+o),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(c=t.ref),t)r.call(t,l)&&!i.hasOwnProperty(l)&&(d[l]=t[l]);if(e&&e.defaultProps)for(l in t=e.defaultProps)void 0===d[l]&&(d[l]=t[l]);return{$$typeof:a,type:e,key:s,ref:c,props:d,_owner:n.current}}},706:(e,t,o)=>{e.exports=o(418)},445:(e,t,o)=>{var l=o(609);const a=window.wp.blocks,r=window.wp.i18n,n=window.wp.primitives;var i=o(706);const d=(0,i.jsx)(n.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(n.Path,{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6.5c-1.4 0-2.5-1.1-2.5-2.5s1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5-1.1 2.5-2.5 2.5zM12.8 3h-1.5v3h1.5V3zm-1.6 18h1.5v-3h-1.5v3zm6.8-9.8v1.5h3v-1.5h-3zm-12 0H3v1.5h3v-1.5zm9.7 5.6 2.1 2.1 1.1-1.1-2.1-2.1-1.1 1.1zM8.3 7.2 6.2 5.1 5.1 6.2l2.1 2.1 1.1-1.1zM5.1 17.8l1.1 1.1 2.1-2.1-1.1-1.1-2.1 2.1zM18.9 6.2l-1.1-1.1-2.1 2.1 1.1 1.1 2.1-2.1z"})}),s=(0,i.jsx)(n.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(n.Path,{fillRule:"evenodd",d:"M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z",clipRule:"evenodd"})}),c=window.wp.element,u=window.wp.blockEditor,p=window.wp.components,g=({label:e,value:t,unit:o,onValueChange:a,onUnitChange:n})=>(0,l.createElement)(p.Flex,null,(0,l.createElement)(p.FlexBlock,null,(0,l.createElement)(p.TextControl,{label:e,value:parseInt(t),onChange:e=>a(e)})),(0,l.createElement)(p.FlexItem,null,(0,l.createElement)(p.SelectControl,{label:(0,r.__)("Unit","wedocs"),value:o,options:[{label:"px",value:"px"},{label:"%",value:"%"}],onChange:e=>n(e)}))),m=({selected:e,options:t,onChange:o})=>(0,l.createElement)(p.BaseControl,null,(0,l.createElement)("div",{className:"radio-image-control-options"},t.map((t=>(0,l.createElement)("div",{key:t.value,className:"radio-image-option"},(0,l.createElement)("input",{type:"radio",id:`radio-image-${t.value}`,value:t.value,checked:e===t.value,onChange:e=>o(e.target.value)}),(0,l.createElement)("label",{htmlFor:`radio-image-${t.value}`},t.icon&&(0,l.createElement)("i",{className:`dashicons ${t.icon}`}),t.img&&(0,l.createElement)("img",{src:t.img,alt:t.label}),t?.svg)))))),b={hideSearch:{type:"boolean",default:!1},searchWidth:{type:"number",default:50},widthUnit:{type:"string",default:"%"},placeholder:{type:"string",default:(0,r.__)("Search for a top or question","wedocs")},alignment:{type:"string",default:"right"},bgColor:{type:"string",default:"#FFFFFF"},hoverColor:{type:"string",default:"#FFFFFF"},padding:{type:"object",default:{top:14,left:22,right:22,bottom:14}},margin:{type:"object",default:{top:0,left:0,right:0,bottom:0}},borderColor:{type:"string",default:"#cccccc"},borderType:{type:"string",default:"solid"},borderWidth:{type:"number",default:1},borderRadius:{type:"number",default:30},iconColor:{type:"string",default:"#FFFFFF"},iconBgColor:{type:"string",default:"#3b82f6"},iconHoverColor:{type:"string",default:"#2563eb"},svgHoverColor:{type:"string",default:"#FFFFFF"},btnPadding:{type:"object",default:{top:24,left:26,right:26,bottom:24}},btnPosition:{type:"object",default:{top:0,right:0,bottom:10}},btnRadius:{type:"number",default:30}};(0,a.registerBlockType)("wedocs/wedocs-search",{attributes:b,save:({attributes:e})=>{const{margin:t,bgColor:o,padding:a,btnRadius:r,alignment:n,iconColor:i,widthUnit:d,hoverColor:s,borderType:p,hideSearch:g,btnPadding:m,searchWidth:b,btnPosition:h,placeholder:_,borderColor:v,borderWidth:C,iconBgColor:w,borderRadius:f,svgHoverColor:E,iconHoverColor:x}=e;if(g)return;const y={display:"flex",justifyContent:n},B={border:`${C}px ${p} ${v}`,paddingTop:a?.top,paddingLeft:a?.left,paddingRight:a?.right,borderRadius:`${f}px`,paddingBottom:a?.bottom,"--field-color":o,"--field-bg-color":s},S={top:h?.top,left:h?.left,right:h?.right,bottom:h?.bottom,height:"auto",paddingTop:m?.top,paddingLeft:m?.left,borderRadius:r,paddingRight:m?.right,paddingBottom:m?.bottom,"--field-icon-color":i,"--field-btn-bg-color":w,"--field-icon-hover-color":E,"--field-btn-bg-hover-color":x};return(0,l.createElement)(c.Fragment,null,(0,l.createElement)("form",{method:"get",role:"search",action:weDocsBlockVars?.siteUrl,...u.useBlockProps.save({className:"search-form wedocs-search-form"})},(0,l.createElement)("div",{style:y},(0,l.createElement)("div",{className:"wedocs-search-input",style:{width:b+d,marginTop:t?.top,marginLeft:t?.left,marginRight:t?.right,marginBottom:t?.bottom}},(0,l.createElement)("input",{name:"s",type:"search",style:B,className:"search-field",placeholder:_}),(0,l.createElement)("input",{type:"hidden",name:"post_type",value:"docs"}),(0,l.createElement)("button",{type:"submit",style:S,className:"search-submit"},(0,l.createElement)("svg",{width:"15",height:"16",fill:"none"},(0,l.createElement)("path",{fillRule:"evenodd",d:"M11.856 10.847l2.883 2.883a.89.89 0 0 1 0 1.257c-.173.174-.401.261-.629.261s-.455-.087-.629-.261l-2.883-2.883c-1.144.874-2.532 1.353-3.996 1.353a6.56 6.56 0 0 1-4.671-1.935c-2.576-2.575-2.576-6.765 0-9.341C3.179.934 4.839.247 6.603.247s3.424.687 4.671 1.935a6.56 6.56 0 0 1 1.935 4.67 6.55 6.55 0 0 1-1.353 3.995zM3.189 3.439c-1.882 1.882-1.882 4.945 0 6.827.912.912 2.124 1.414 3.414 1.414s2.502-.502 3.414-1.414 1.414-2.124 1.414-3.413-.502-2.502-1.414-3.413-2.124-1.414-3.414-1.414-2.502.502-3.414 1.414z"})))))))},edit:({attributes:e,setAttributes:t})=>{const o=(0,u.useBlockProps)(),{margin:a,bgColor:n,padding:i,btnRadius:b,alignment:h,iconColor:_,widthUnit:v,hoverColor:C,borderType:w,hideSearch:f,btnPadding:E,searchWidth:x,btnPosition:y,placeholder:B,borderColor:S,borderWidth:k,iconBgColor:F,borderRadius:P,svgHoverColor:R,iconHoverColor:T}=e;console.log("editor panel:",n);const M=[{value:"left",label:(0,r.__)("Align left","wedocs"),svg:(0,l.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"left"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,l.createElement)("path",{d:"M8 9.462h12m-12 6h6m-10-9v12"}))},{value:"center",label:(0,r.__)("Align center","wedocs"),svg:(0,l.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"center"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,l.createElement)("path",{d:"M18 9.462H6m8.99 6h-6"}),(0,l.createElement)("path",{d:"M12 6.462v12"}))},{value:"right",label:(0,r.__)("Align right","wedocs"),svg:(0,l.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"right"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,l.createElement)("path",{d:"M16 9.462H4m12 6h-6m10-9v12"}))}],[N,D]=(0,c.useState)(!1),[O,$]=(0,c.useState)(!1),[L,A]=(0,c.useState)(!1),H={display:"flex",justifyContent:h},j={border:`${k}px ${w} ${S}`,paddingTop:i?.top,background:N?C:n,paddingLeft:i?.left,paddingRight:i?.right,borderRadius:`${P}px`,paddingBottom:i?.bottom},I={top:y?.top,left:y?.left,right:y?.right,bottom:y?.bottom,height:"auto",background:L?T:F,paddingTop:E?.top,paddingLeft:E?.left,borderRadius:b,paddingRight:E?.right,paddingBottom:E?.bottom},V=[{label:(0,r.__)("Solid","wedocs"),value:"solid"},{label:(0,r.__)("Dotted","wedocs"),value:"dotted"},{label:(0,r.__)("Dashed","wedocs"),value:"dashed"},{label:(0,r.__)("Double","wedocs"),value:"double"},{label:(0,r.__)("Groove","wedocs"),value:"groove"},{label:(0,r.__)("Ridge","wedocs"),value:"ridge"},{label:(0,r.__)("Inset","wedocs"),value:"inset"},{label:(0,r.__)("Outset","wedocs"),value:"outset"},{label:(0,r.__)("None","wedocs"),value:"none"},{label:(0,r.__)("Hidden","wedocs"),value:"hidden"}];return(0,l.createElement)(c.Fragment,null,(0,l.createElement)(u.InspectorControls,null,(0,l.createElement)(p.PanelBody,null,(0,l.createElement)(p.ToggleControl,{checked:f,className:"wedocs-search-toggle",label:(0,r.__)("Disable Block","wedocs"),onChange:e=>t({hideSearch:e})})),!f&&(0,l.createElement)(c.Fragment,null,(0,l.createElement)(p.PanelBody,{title:(0,r.__)("Color Settings","wedocs"),icon:d,initialOpen:!1,className:"wedocs-search-color-settings"},(0,l.createElement)(u.PanelColorSettings,{colors:[{name:"Sweet",color:"#F43F5E"},{name:"Orange",color:"#F97316"},{name:"Yellow",color:"#FACC15"},{name:"Purple",color:"#8B5CF6"},{name:"Light Blue",color:"#3B82F6"},{name:"Light Green",color:"#10B981"}],colorSettings:[{value:n,label:(0,r.__)("Field Background Color","wedocs"),onChange:e=>t({bgColor:e})},{value:C,label:(0,r.__)("Field Hover Color","wedocs"),onChange:e=>t({hoverColor:e})},{value:S,label:(0,r.__)("Border Color","wedocs"),onChange:e=>t({borderColor:e})},{value:_,label:(0,r.__)("Icon Color","wedocs"),onChange:e=>t({iconColor:e})},{value:F,label:(0,r.__)("Button Color","wedocs"),onChange:e=>t({iconBgColor:e})},{value:T,label:(0,r.__)("Button Hover Color","wedocs"),onChange:e=>t({iconHoverColor:e})},{value:R,label:(0,r.__)("Icon Hover Color","wedocs"),onChange:e=>t({svgHoverColor:e})}]})),(0,l.createElement)(p.PanelBody,{title:(0,r.__)("Search Bar Settings","wedocs"),icon:s},(0,l.createElement)(g,{unit:v,value:x,label:(0,r.__)("Field Width","wedocs"),onUnitChange:e=>t({widthUnit:e}),onValueChange:e=>t({searchWidth:e?parseInt(e):0})}),(0,l.createElement)(p.TextControl,{value:B,label:(0,r.__)("Placeholder","wedocs"),placeholder:(0,r.__)("Search bar placeholder","wedocs"),onChange:e=>t({placeholder:e})}),(0,l.createElement)("p",{style:{fontSize:11}},(0,r.__)("POSITION","wedocs")),(0,l.createElement)(m,{selected:h,options:M,onChange:e=>t({alignment:e})}),(0,l.createElement)(p.__experimentalBoxControl,{resetValues:{top:"14px",left:"22px",right:"22px",bottom:"14px"},values:i,label:(0,r.__)("Field Padding","wedocs"),onChange:e=>t({padding:e})}),(0,l.createElement)(p.__experimentalBoxControl,{resetValues:{top:"0px",left:"0px",right:"0px",bottom:"0px"},values:a,label:(0,r.__)("Field Margin","wedocs"),onChange:e=>t({margin:e})}),(0,l.createElement)(p.RangeControl,{min:0,max:10,value:k,label:(0,r.__)("Border Width","wedocs"),onChange:e=>t({borderWidth:e})}),(0,l.createElement)(p.RangeControl,{min:0,max:100,value:P,label:(0,r.__)("Border Radius","wedocs"),onChange:e=>t({borderRadius:e})}),(0,l.createElement)(p.SelectControl,{value:w,options:V,label:(0,r.__)("Border Type","wedocs"),onChange:e=>t({borderType:e})}),(0,l.createElement)(p.__experimentalBoxControl,{resetValues:{top:"24px",left:"26px",right:"26px",bottom:"24px"},values:E,label:(0,r.__)("Button Padding","wedocs"),onChange:e=>t({btnPadding:e})}),(0,l.createElement)(p.__experimentalBoxControl,{resetValues:{top:"0px",right:"0px",bottom:"10px"},values:y,label:(0,r.__)("Button Margin","wedocs"),onChange:e=>t({btnPosition:e})}),(0,l.createElement)(p.RangeControl,{min:0,max:100,value:b,label:(0,r.__)("Button Radius","wedocs"),onChange:e=>t({btnRadius:e})})))),(0,l.createElement)("div",{...o,style:H},(0,l.createElement)("div",{className:"wedocs-editor-search-input",style:{width:x+v,marginTop:a?.top,marginLeft:a?.left,marginRight:a?.right,marginBottom:a?.bottom}},(0,l.createElement)("input",{readOnly:!0,style:j,className:"search-field",placeholder:B,onMouseEnter:()=>D(!0),onMouseLeave:()=>D(!1)}),(0,l.createElement)("input",{type:"hidden",name:"post_type",value:"docs"}),(0,l.createElement)("button",{type:"submit",style:I,className:"search-submit",onMouseEnter:()=>A(!0),onMouseLeave:()=>A(!1)},(0,l.createElement)("svg",{width:"15",height:"16",fill:"none",onMouseEnter:()=>$(!0),onMouseLeave:()=>$(!1)},(0,l.createElement)("path",{fill:O?R:_,fillRule:"evenodd",d:"M11.856 10.847l2.883 2.883a.89.89 0 0 1 0 1.257c-.173.174-.401.261-.629.261s-.455-.087-.629-.261l-2.883-2.883c-1.144.874-2.532 1.353-3.996 1.353a6.56 6.56 0 0 1-4.671-1.935c-2.576-2.575-2.576-6.765 0-9.341C3.179.934 4.839.247 6.603.247s3.424.687 4.671 1.935a6.56 6.56 0 0 1 1.935 4.67 6.55 6.55 0 0 1-1.353 3.995zM3.189 3.439c-1.882 1.882-1.882 4.945 0 6.827.912.912 2.124 1.414 3.414 1.414s2.502-.502 3.414-1.414 1.414-2.124 1.414-3.413-.502-2.502-1.414-3.413-2.124-1.414-3.414-1.414-2.502.502-3.414 1.414z"})))),f&&(0,l.createElement)("div",{className:"backdrop"})))},icon:(0,l.createElement)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},(0,l.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.91421 1.5H5.5C4.39543 1.5 3.5 2.39543 3.5 3.5V6.91421V9.02779V15.5C3.5 16.6046 4.39543 17.5 5.5 17.5H7.02779C6.07771 16.4385 5.5 15.0367 5.5 13.5C5.5 10.1863 8.18629 7.5 11.5 7.5C13.0367 7.5 14.4385 8.07771 15.5 9.02779V8.5V6.91421C15.5 6.38378 15.2893 5.87507 14.9142 5.5L11.5 2.08579C11.1249 1.71071 10.6162 1.5 10.0858 1.5H8.91421ZM15.5 13.5C15.5 11.2909 13.7091 9.5 11.5 9.5C9.29086 9.5 7.5 11.2909 7.5 13.5C7.5 15.7091 9.29086 17.5 11.5 17.5C12.2414 17.5 12.9364 17.2977 13.5318 16.946L14.7929 18.2071C15.1834 18.5976 15.8166 18.5976 16.2071 18.2071C16.5976 17.8166 16.5976 17.1834 16.2071 16.7929L14.946 15.5318C15.2977 14.9364 15.5 14.2414 15.5 13.5ZM11.5 11.5C12.6046 11.5 13.5 12.3954 13.5 13.5C13.5 14.0526 13.2772 14.5512 12.9142 14.9142C12.5512 15.2772 12.0526 15.5 11.5 15.5C10.3954 15.5 9.5 14.6046 9.5 13.5C9.5 12.3954 10.3954 11.5 11.5 11.5Z",fill:"#111827"})),title:(0,r.__)("weDocs - Searchbar","wedocs"),keywords:["Search","weDocs search bar","Bar"],category:"widgets",description:(0,r.__)("Simple search forms for easy user guidance for your documentation","wedocs")});const h=({attributes:e,setAttributes:t})=>{const o=e=>o=>{t({[e]:o})},a=((0,r.__)("Solid","wedocs"),(0,r.__)("Dashed","wedocs"),(0,r.__)("Dotted","wedocs"),(0,r.__)("None","wedocs"),[{name:"Sweet",color:"#F43F5E"},{name:"Orange",color:"#F97316"},{name:"Yellow",color:"#FACC15"},{name:"Purple",color:"#8B5CF6"},{name:"Light Blue",color:"#3B82F6"},{name:"Light Green",color:"#10B981"}]);return(0,l.createElement)(l.Fragment,null,(0,l.createElement)(p.PanelBody,{title:(0,r.__)("Grid Styles","wedocs"),icon:"admin-appearance",initialOpen:!1},(0,l.createElement)("label",null,(0,r.__)("Colors","wedocs")),(0,l.createElement)(u.PanelColorSettings,{colors:a,colorSettings:[{value:e.docTitleColor,label:(0,r.__)("Doc Title Color","wedocs"),onChange:e=>o("docTitleColor")(e)},{value:e.docChildrenActiveColor,label:(0,r.__)("Doc Children Active Color","wedocs"),onChange:e=>o("docChildrenActiveColor")(e)},{value:e.borderColor,label:(0,r.__)("Border Color","wedocs"),onChange:e=>o("borderColor")(e)}]}),(0,l.createElement)(p.__experimentalBoxControl,{label:(0,r.__)("Grid Padding","wedocs"),values:e.gridPadding,onChange:o("gridPadding")}),(0,l.createElement)(p.__experimentalBoxControl,{label:(0,r.__)("Grid Margin","wedocs"),values:e.gridMargin,onChange:o("gridMargin")}),(0,l.createElement)(p.SelectControl,{label:(0,r.__)("Border Type","wedocs"),value:e.borderType,options:[{label:(0,r.__)("Solid","wedocs"),value:"solid"},{label:(0,r.__)("Dashed","wedocs"),value:"dashed"},{label:(0,r.__)("Dotted","wedocs"),value:"dotted"},{label:(0,r.__)("None","wedocs"),value:"none"}],onChange:e=>t({borderType:e})}),(0,l.createElement)(p.SelectControl,{label:(0,r.__)("Border Width","wedocs"),value:e.borderWidth,options:[{label:"0px",value:"0px"},{label:"1px",value:"1px"},{label:"2px",value:"2px"},{label:"3px",value:"3px"},{label:"4px",value:"4px"},{label:"5px",value:"5px"}],onChange:e=>t({borderWidth:e})}),(0,l.createElement)(p.SelectControl,{label:(0,r.__)("Border Radius","wedocs"),value:e.borderRadius,options:[{label:"0px",value:"0px"},{label:"4px",value:"4px"},{label:"8px",value:"8px"},{label:"12px",value:"12px"},{label:"16px",value:"16px"},{label:"20px",value:"20px"}],onChange:e=>t({borderRadius:e})})),(0,l.createElement)(p.PanelBody,{title:(0,r.__)("Button Styles","wedocs"),icon:"admin-appearance",initialOpen:!1},(0,l.createElement)("label",null,(0,r.__)("Button Colors","wedocs")),(0,l.createElement)(u.PanelColorSettings,{colors:a,colorSettings:[{value:e.buttonColor,label:(0,r.__)("Button Color","wedocs"),onChange:e=>o("buttonColor")(e)},{value:e.buttonHoverColor,label:(0,r.__)("Button Hover Color","wedocs"),onChange:e=>o("buttonHoverColor")(e)},{value:e.buttonTextColor,label:(0,r.__)("Button Text Color","wedocs"),onChange:e=>o("buttonTextColor")(e)},{value:e.buttonHoverTextColor,label:(0,r.__)("Button Hover Text Color","wedocs"),onChange:e=>o("buttonHoverTextColor")(e)}]}),(0,l.createElement)(p.__experimentalBoxControl,{label:(0,r.__)("Button Padding","wedocs"),values:e.buttonPadding,onChange:o("buttonPadding")}),(0,l.createElement)(p.__experimentalBoxControl,{label:(0,r.__)("Button Margin","wedocs"),values:e.buttonMargin,onChange:o("buttonMargin")}),(0,l.createElement)(p.SelectControl,{label:(0,r.__)("Button Border Radius","wedocs"),value:e.buttonBorderRadius,options:[{label:"0px",value:"0px"},{label:"4px",value:"4px"},{label:"8px",value:"8px"},{label:"12px",value:"12px"},{label:"16px",value:"16px"},{label:"20px",value:"20px"}],onChange:e=>t({buttonBorderRadius:e})}),(0,l.createElement)("div",{className:"wedocs-color-control"},(0,l.createElement)("label",null,(0,r.__)("Button Text","wedocs")),(0,l.createElement)(p.TextControl,{value:e.buttonText,onChange:o("buttonText")}))))},_=JSON.parse('{"UU":"wedocs/wedocs-docs-grid"}');(0,a.registerBlockType)(_.UU,{edit:({attributes:e,setAttributes:t})=>{const o=(0,u.useBlockProps)(),{useSelect:a}=wp.data,[n,i]=(0,c.useState)(1),[d,g]=(0,c.useState)(!1),{hideDocGrid:m,docStyle:b,docsPerPage:_,excludeDocs:v,order:C,orderBy:w,sectionsPerDoc:f,articlesPerSection:E,showDocArticle:x,keepArticlesCollapsed:y,showViewDetails:B,gridPadding:S,gridMargin:k,docTitleColor:F,docChildrenActiveColor:P,borderType:R,borderRadius:T,borderWidth:M,borderColor:N,buttonBorderRadius:D,buttonPadding:O,buttonMargin:$,buttonColor:L,buttonHoverColor:A,buttonTextColor:H,buttonText:j,buttonHoverTextColor:I}=e,V=[{label:"All",value:"all"},...Array.from({length:10},((e,t)=>({label:String(t+1),value:String(t+1)})))],W=[{label:(0,r.__)("weDocs Order","wedocs"),value:"menu_order"},{label:(0,r.__)("ID","wedocs"),value:"id"},{label:(0,r.__)("Name","wedocs"),value:"title"}],z=[{label:(0,r.__)("Ascending","wedocs"),value:"asc"},{label:(0,r.__)("Descending","wedocs"),value:"desc"}],U=[{label:"All",value:"all"},...Array.from({length:10},((e,t)=>({label:String(t+1),value:String(t+1)})))],{pages:G,sections:Y,articles:Z}=a((e=>{const{getEntityRecords:t}=e("core"),o=t("postType","docs",{status:"publish",per_page:-1,parent:0,orderby:w,order:C}),l=o?t("postType","docs",{status:"publish",parent_in:o.map((e=>e.id)),per_page:-1}):null,a=l?t("postType","docs",{status:"publish",parent_in:l.map((e=>e.id)),per_page:-1}):null;return{pages:o,sections:l,articles:a}}),[w,C]),q=(e=>{if("all"===_)return e;const t=parseInt(_),o=(n-1)*t,l=o+t;return e.slice(o,l)})((()=>{if(!G||!Y||!Z)return[];let e=[...G];return v&&v.length>0&&(e=e.filter((e=>!v.includes(e.id.toString())))),e=e.map((e=>{let t=Y.filter((t=>t.parent===e.id));"all"!==f&&(t=t.slice(0,parseInt(f))),t=t.map((e=>{let t=Z.filter((t=>t.parent===e.id));return"all"!==E&&(t=t.slice(0,parseInt(E))),{...e,articles:t}}));const o=t.reduce(((e,t)=>e+t.articles.length),0);return{...e,sections:t,articleCount:o}})),e})()),J=G?G.reduce(((e,t)=>(e[t.id]=t.title.rendered,e)),{}):{},K=(G&&G.map((e=>({value:e.id.toString(),label:e.title.rendered}))),e=>o=>{t({[e]:o})}),Q=v?v.map((e=>J[e]||e)):[];return(0,l.createElement)(c.Fragment,null,(0,l.createElement)(u.InspectorControls,null,(0,l.createElement)(p.PanelBody,{title:(0,r.__)("Doc Grid Settings","wedocs"),icon:s,initialOpen:!1},(0,l.createElement)(p.SelectControl,{value:b,options:[{label:"1x1",value:"1x1"},{label:"1x2",value:"1x2"}],label:(0,r.__)("DOCS GRID COLUMN STYLE","wedocs"),onChange:K("docStyle")}),(0,l.createElement)(p.SelectControl,{value:_,options:V,label:(0,r.__)("Docs per page","wedocs"),onChange:K("docsPerPage")}),(0,l.createElement)(p.FormTokenField,{value:Q,suggestions:Object.values(J),label:(0,r.__)("Exclude Docs","wedocs"),onChange:e=>{const o=e.map((e=>{const t=Object.entries(J).find((([t,o])=>o===e));return t?t[0]:e}));t({excludeDocs:o})}}),(0,l.createElement)(p.SelectControl,{value:C,options:z,label:(0,r.__)("Order","wedocs"),onChange:K("order")}),(0,l.createElement)(p.SelectControl,{value:w,options:W,label:(0,r.__)("Order by","wedocs"),onChange:K("orderBy")}),(0,l.createElement)(p.SelectControl,{value:f,options:U,label:(0,r.__)("Sections per doc","wedocs"),onChange:K("sectionsPerDoc")}),(0,l.createElement)(p.SelectControl,{value:E,options:U,label:(0,r.__)("Articles per section","wedocs"),onChange:K("articlesPerSection")}),(0,l.createElement)(p.PanelRow,null,(0,l.createElement)(p.ToggleControl,{checked:x,label:(0,r.__)("Show Doc Article","wedocs"),onChange:K("showDocArticle")})),(0,l.createElement)(p.PanelRow,null,(0,l.createElement)(p.ToggleControl,{checked:y,label:(0,r.__)("Keep Article Collapsed","wedocs"),onChange:K("keepArticlesCollapsed")})),(0,l.createElement)(p.PanelRow,null,(0,l.createElement)(p.ToggleControl,{checked:B,label:(0,r.__)("Show View Details Button","wedocs"),onChange:K("showViewDetails")})))),(0,l.createElement)(u.InspectorControls,null,(0,l.createElement)(h,{attributes:e,setAttributes:t})),(0,l.createElement)("div",{...o},m?(0,l.createElement)("div",{className:"backdrop"}):(0,l.createElement)("div",{className:"wedocs-block-wrapper"},(0,l.createElement)("div",{className:`wedocs-docs-grid wedocs-docs-grid--${b}`},d?(0,l.createElement)(Spinner,null):q.map((e=>((e,t)=>(0,l.createElement)("div",{key:e.id,className:"wedocs-docs-grid__item",style:t.item},(0,l.createElement)("h3",{className:"wedocs-docs-grid__title",style:t.title},e.title.rendered),((e,t)=>e.sections?(0,l.createElement)("div",{className:"wedocs-docs-grid__sections "+(y?"is-collapsed":"")},e.sections.map((e=>(0,l.createElement)("div",{key:e.id,className:"wedocs-docs-grid__section"},(0,l.createElement)("h4",{className:"wedocs-docs-grid__section-title",style:{...t.title,display:"flex",justifyContent:"space-between",alignItems:"center"}},(0,l.createElement)("span",null,e.title.rendered),x&&e.articles&&e.articles.length>0&&(0,l.createElement)("svg",{fill:"none",viewBox:"0 0 24 24",width:"16",strokeWidth:"2",stroke:"#acb8c4",className:y?"":"active"},(0,l.createElement)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"}))),x&&!y&&e.articles&&(0,l.createElement)("ul",{className:"wedocs-docs-grid__articles"},e.articles.map((e=>(0,l.createElement)("li",{key:e.id,className:"wedocs-docs-grid__article",style:t.children},e.title.rendered))))))),0===e.sections.length&&(0,l.createElement)("span",{className:"inside"},(0,l.createElement)("svg",{fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},(0,l.createElement)("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"})),(0,r.__)("This document has no sections yet. Check back later or wait for the author to add content.","wedocs"))):null)(e,t),B&&(0,l.createElement)("div",{className:"wedocs-docs-grid__details"},(0,l.createElement)("span",{className:"wedocs-docs-grid__details-link",style:t.button},t.button.text))))(e,(()=>{const e=S?`${S.top} ${S.right} ${S.bottom} ${S.left}`:"",t=k?`${k.top} ${k.right} ${k.bottom} ${k.left}`:"",o=O?`${O.top} ${O.right} ${O.bottom} ${O.left}`:"",l=D||"8px",a=$?`${$.top} ${$.right} ${$.bottom} ${$.left}`:"";return{item:{padding:e,margin:t,borderStyle:R||"solid",borderWidth:M||"1px",borderColor:N||"rgba(0, 0, 0, 0.1)",borderRadius:T||"8px",backgroundColor:"#fff"},title:{color:F||"#1e1e1e"},children:{color:P||"#0073aa"},button:{padding:o,margin:a,backgroundColor:L||"#0073aa",color:H||"#ffffff",text:j||(0,r.__)("View Details","wedocs"),borderRadius:l||"8px","--hover-bg":A||"#005177","--hover-color":I||"#ffffff"}}})())))))))},save:()=>null})},609:e=>{e.exports=window.React}},o={};function l(e){var a=o[e];if(void 0!==a)return a.exports;var r=o[e]={exports:{}};return t[e](r,r.exports,l),r.exports}l.m=t,e=[],l.O=(t,o,a,r)=>{if(!o){var n=1/0;for(c=0;c<e.length;c++){o=e[c][0],a=e[c][1],r=e[c][2];for(var i=!0,d=0;d<o.length;d++)(!1&r||n>=r)&&Object.keys(l.O).every((e=>l.O[e](o[d])))?o.splice(d--,1):(i=!1,r<n&&(n=r));if(i){e.splice(c--,1);var s=a();void 0!==s&&(t=s)}}return t}r=r||0;for(var c=e.length;c>0&&e[c-1][2]>r;c--)e[c]=e[c-1];e[c]=[o,a,r]},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={366:0,337:0};l.O.j=t=>0===e[t];var t=(t,o)=>{var a,r,n=o[0],i=o[1],d=o[2],s=0;if(n.some((t=>0!==e[t]))){for(a in i)l.o(i,a)&&(l.m[a]=i[a]);if(d)var c=d(l)}for(t&&t(o);s<n.length;s++)r=n[s],l.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return l.O(c)},o=self.webpackChunkweDocs=self.webpackChunkweDocs||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var a=l.O(void 0,[337],(()=>l(445)));a=l.O(a)})(); No newline at end of file | |||
| (()=>{"use strict";var e,t={418:(e,t,l)=>{var o=l(609),a=Symbol.for("react.element"),n=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),r=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,l){var o,c={},d=null,s=null;for(o in void 0!==l&&(d=""+l),void 0!==t.key&&(d=""+t.key),void 0!==t.ref&&(s=t.ref),t)n.call(t,o)&&!i.hasOwnProperty(o)&&(c[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===c[o]&&(c[o]=t[o]);return{$$typeof:a,type:e,key:d,ref:s,props:c,_owner:r.current}}},706:(e,t,l)=>{e.exports=l(418)},870:(e,t,l)=>{var o=l(609);const a=window.wp.blocks,n=window.wp.i18n,r=window.wp.primitives;var i=l(706);const c=(0,i.jsx)(r.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(r.Path,{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6.5c-1.4 0-2.5-1.1-2.5-2.5s1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5-1.1 2.5-2.5 2.5zM12.8 3h-1.5v3h1.5V3zm-1.6 18h1.5v-3h-1.5v3zm6.8-9.8v1.5h3v-1.5h-3zm-12 0H3v1.5h3v-1.5zm9.7 5.6 2.1 2.1 1.1-1.1-2.1-2.1-1.1 1.1zM8.3 7.2 6.2 5.1 5.1 6.2l2.1 2.1 1.1-1.1zM5.1 17.8l1.1 1.1 2.1-2.1-1.1-1.1-2.1 2.1zM18.9 6.2l-1.1-1.1-2.1 2.1 1.1 1.1 2.1-2.1z"})}),d=(0,i.jsx)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(r.Path,{fillRule:"evenodd",d:"M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z",clipRule:"evenodd"})}),s=window.wp.element,u=window.wp.blockEditor,m=window.wp.components,p=({label:e,value:t,unit:l,onValueChange:a,onUnitChange:r})=>(0,o.createElement)(m.Flex,null,(0,o.createElement)(m.FlexBlock,null,(0,o.createElement)(m.TextControl,{label:e,value:parseInt(t),onChange:e=>a(e)})),(0,o.createElement)(m.FlexItem,null,(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Unit","wedocs"),value:l,options:[{label:"px",value:"px"},{label:"%",value:"%"}],onChange:e=>r(e)}))),g=({selected:e,options:t,onChange:l})=>(0,o.createElement)(m.BaseControl,null,(0,o.createElement)("div",{className:"radio-image-control-options"},t.map((t=>(0,o.createElement)("div",{key:t.value,className:"radio-image-option"},(0,o.createElement)("input",{type:"radio",id:`radio-image-${t.value}`,value:t.value,checked:e===t.value,onChange:e=>l(e.target.value)}),(0,o.createElement)("label",{htmlFor:`radio-image-${t.value}`},t.icon&&(0,o.createElement)("i",{className:`dashicons ${t.icon}`}),t.img&&(0,o.createElement)("img",{src:t.img,alt:t.label}),t?.svg)))))),b={hideSearch:{type:"boolean",default:!1},searchWidth:{type:"number",default:50},widthUnit:{type:"string",default:"%"},placeholder:{type:"string",default:(0,n.__)("Search for a top or question","wedocs")},alignment:{type:"string",default:"right"},bgColor:{type:"string",default:"#FFFFFF"},hoverColor:{type:"string",default:"#FFFFFF"},padding:{type:"object",default:{top:14,left:22,right:22,bottom:14}},margin:{type:"object",default:{top:0,left:0,right:0,bottom:0}},borderColor:{type:"string",default:"#cccccc"},borderType:{type:"string",default:"solid"},borderWidth:{type:"number",default:1},borderRadius:{type:"number",default:30},iconColor:{type:"string",default:"#FFFFFF"},iconBgColor:{type:"string",default:"#3b82f6"},iconHoverColor:{type:"string",default:"#2563eb"},svgHoverColor:{type:"string",default:"#FFFFFF"},btnPadding:{type:"object",default:{top:24,left:26,right:26,bottom:24}},btnPosition:{type:"object",default:{top:0,right:0,bottom:10}},btnRadius:{type:"number",default:30}};(0,a.registerBlockType)("wedocs/wedocs-search",{attributes:b,save:({attributes:e})=>{const{margin:t,bgColor:l,padding:a,btnRadius:n,alignment:r,iconColor:i,widthUnit:c,hoverColor:d,borderType:m,hideSearch:p,btnPadding:g,searchWidth:b,btnPosition:h,placeholder:_,borderColor:v,borderWidth:C,iconBgColor:w,borderRadius:E,svgHoverColor:x,iconHoverColor:f}=e;if(p)return;const y={display:"flex",justifyContent:r},B={border:`${C}px ${m} ${v}`,paddingTop:a?.top,paddingLeft:a?.left,paddingRight:a?.right,borderRadius:`${E}px`,paddingBottom:a?.bottom,"--field-color":l,"--field-bg-color":d},S={top:h?.top,left:h?.left,right:h?.right,bottom:h?.bottom,height:"auto",paddingTop:g?.top,paddingLeft:g?.left,borderRadius:n,paddingRight:g?.right,paddingBottom:g?.bottom,"--field-icon-color":i,"--field-btn-bg-color":w,"--field-icon-hover-color":x,"--field-btn-bg-hover-color":f};return(0,o.createElement)(s.Fragment,null,(0,o.createElement)("form",{method:"get",role:"search",action:weDocsBlockVars?.siteUrl,...u.useBlockProps.save({className:"search-form wedocs-search-form"})},(0,o.createElement)("div",{style:y},(0,o.createElement)("div",{className:"wedocs-search-input",style:{width:b+c,marginTop:t?.top,marginLeft:t?.left,marginRight:t?.right,marginBottom:t?.bottom}},(0,o.createElement)("input",{name:"s",type:"search",style:B,className:"search-field",placeholder:_}),(0,o.createElement)("input",{type:"hidden",name:"post_type",value:"docs"}),(0,o.createElement)("button",{type:"submit",style:S,className:"search-submit"},(0,o.createElement)("svg",{width:"15",height:"16",fill:"none"},(0,o.createElement)("path",{fillRule:"evenodd",d:"M11.856 10.847l2.883 2.883a.89.89 0 0 1 0 1.257c-.173.174-.401.261-.629.261s-.455-.087-.629-.261l-2.883-2.883c-1.144.874-2.532 1.353-3.996 1.353a6.56 6.56 0 0 1-4.671-1.935c-2.576-2.575-2.576-6.765 0-9.341C3.179.934 4.839.247 6.603.247s3.424.687 4.671 1.935a6.56 6.56 0 0 1 1.935 4.67 6.55 6.55 0 0 1-1.353 3.995zM3.189 3.439c-1.882 1.882-1.882 4.945 0 6.827.912.912 2.124 1.414 3.414 1.414s2.502-.502 3.414-1.414 1.414-2.124 1.414-3.413-.502-2.502-1.414-3.413-2.124-1.414-3.414-1.414-2.502.502-3.414 1.414z"})))))))},edit:({attributes:e,setAttributes:t})=>{const l=(0,u.useBlockProps)(),{margin:a,bgColor:r,padding:i,btnRadius:b,alignment:h,iconColor:_,widthUnit:v,hoverColor:C,borderType:w,hideSearch:E,btnPadding:x,searchWidth:f,btnPosition:y,placeholder:B,borderColor:S,borderWidth:k,iconBgColor:P,borderRadius:T,svgHoverColor:F,iconHoverColor:R}=e;console.log("editor panel:",r);const $=[{value:"left",label:(0,n.__)("Align left","wedocs"),svg:(0,o.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"left"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,o.createElement)("path",{d:"M8 9.462h12m-12 6h6m-10-9v12"}))},{value:"center",label:(0,n.__)("Align center","wedocs"),svg:(0,o.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"center"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,o.createElement)("path",{d:"M18 9.462H6m8.99 6h-6"}),(0,o.createElement)("path",{d:"M12 6.462v12"}))},{value:"right",label:(0,n.__)("Align right","wedocs"),svg:(0,o.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"right"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,o.createElement)("path",{d:"M16 9.462H4m12 6h-6m10-9v12"}))}],[M,O]=(0,s.useState)(!1),[N,D]=(0,s.useState)(!1),[z,H]=(0,s.useState)(!1),A={display:"flex",justifyContent:h},L={border:`${k}px ${w} ${S}`,paddingTop:i?.top,background:M?C:r,paddingLeft:i?.left,paddingRight:i?.right,borderRadius:`${T}px`,paddingBottom:i?.bottom},W={top:y?.top,left:y?.left,right:y?.right,bottom:y?.bottom,height:"auto",background:z?R:P,paddingTop:x?.top,paddingLeft:x?.left,borderRadius:b,paddingRight:x?.right,paddingBottom:x?.bottom},I=[{label:(0,n.__)("Solid","wedocs"),value:"solid"},{label:(0,n.__)("Dotted","wedocs"),value:"dotted"},{label:(0,n.__)("Dashed","wedocs"),value:"dashed"},{label:(0,n.__)("Double","wedocs"),value:"double"},{label:(0,n.__)("Groove","wedocs"),value:"groove"},{label:(0,n.__)("Ridge","wedocs"),value:"ridge"},{label:(0,n.__)("Inset","wedocs"),value:"inset"},{label:(0,n.__)("Outset","wedocs"),value:"outset"},{label:(0,n.__)("None","wedocs"),value:"none"},{label:(0,n.__)("Hidden","wedocs"),value:"hidden"}];return(0,o.createElement)(s.Fragment,null,(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(m.PanelBody,null,(0,o.createElement)(m.ToggleControl,{checked:E,className:"wedocs-search-toggle",label:(0,n.__)("Disable Block","wedocs"),onChange:e=>t({hideSearch:e})})),!E&&(0,o.createElement)(s.Fragment,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Color Settings","wedocs"),icon:c,initialOpen:!1,className:"wedocs-search-color-settings"},(0,o.createElement)(u.PanelColorSettings,{colors:[{name:"Sweet",color:"#F43F5E"},{name:"Orange",color:"#F97316"},{name:"Yellow",color:"#FACC15"},{name:"Purple",color:"#8B5CF6"},{name:"Light Blue",color:"#3B82F6"},{name:"Light Green",color:"#10B981"}],colorSettings:[{value:r,label:(0,n.__)("Field Background Color","wedocs"),onChange:e=>t({bgColor:e})},{value:C,label:(0,n.__)("Field Hover Color","wedocs"),onChange:e=>t({hoverColor:e})},{value:S,label:(0,n.__)("Border Color","wedocs"),onChange:e=>t({borderColor:e})},{value:_,label:(0,n.__)("Icon Color","wedocs"),onChange:e=>t({iconColor:e})},{value:P,label:(0,n.__)("Button Color","wedocs"),onChange:e=>t({iconBgColor:e})},{value:R,label:(0,n.__)("Button Hover Color","wedocs"),onChange:e=>t({iconHoverColor:e})},{value:F,label:(0,n.__)("Icon Hover Color","wedocs"),onChange:e=>t({svgHoverColor:e})}]})),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Search Bar Settings","wedocs"),icon:d},(0,o.createElement)(p,{unit:v,value:f,label:(0,n.__)("Field Width","wedocs"),onUnitChange:e=>t({widthUnit:e}),onValueChange:e=>t({searchWidth:e?parseInt(e):0})}),(0,o.createElement)(m.TextControl,{value:B,label:(0,n.__)("Placeholder","wedocs"),placeholder:(0,n.__)("Search bar placeholder","wedocs"),onChange:e=>t({placeholder:e})}),(0,o.createElement)("p",{style:{fontSize:11}},(0,n.__)("POSITION","wedocs")),(0,o.createElement)(g,{selected:h,options:$,onChange:e=>t({alignment:e})}),(0,o.createElement)(m.__experimentalBoxControl,{resetValues:{top:"14px",left:"22px",right:"22px",bottom:"14px"},values:i,label:(0,n.__)("Field Padding","wedocs"),onChange:e=>t({padding:e})}),(0,o.createElement)(m.__experimentalBoxControl,{resetValues:{top:"0px",left:"0px",right:"0px",bottom:"0px"},values:a,label:(0,n.__)("Field Margin","wedocs"),onChange:e=>t({margin:e})}),(0,o.createElement)(m.RangeControl,{min:0,max:10,value:k,label:(0,n.__)("Border Width","wedocs"),onChange:e=>t({borderWidth:e})}),(0,o.createElement)(m.RangeControl,{min:0,max:100,value:T,label:(0,n.__)("Border Radius","wedocs"),onChange:e=>t({borderRadius:e})}),(0,o.createElement)(m.SelectControl,{value:w,options:I,label:(0,n.__)("Border Type","wedocs"),onChange:e=>t({borderType:e})}),(0,o.createElement)(m.__experimentalBoxControl,{resetValues:{top:"24px",left:"26px",right:"26px",bottom:"24px"},values:x,label:(0,n.__)("Button Padding","wedocs"),onChange:e=>t({btnPadding:e})}),(0,o.createElement)(m.__experimentalBoxControl,{resetValues:{top:"0px",right:"0px",bottom:"10px"},values:y,label:(0,n.__)("Button Margin","wedocs"),onChange:e=>t({btnPosition:e})}),(0,o.createElement)(m.RangeControl,{min:0,max:100,value:b,label:(0,n.__)("Button Radius","wedocs"),onChange:e=>t({btnRadius:e})})))),(0,o.createElement)("div",{...l,style:A},(0,o.createElement)("div",{className:"wedocs-editor-search-input",style:{width:f+v,marginTop:a?.top,marginLeft:a?.left,marginRight:a?.right,marginBottom:a?.bottom}},(0,o.createElement)("input",{readOnly:!0,style:L,className:"search-field",placeholder:B,onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1)}),(0,o.createElement)("input",{type:"hidden",name:"post_type",value:"docs"}),(0,o.createElement)("button",{type:"submit",style:W,className:"search-submit",onMouseEnter:()=>H(!0),onMouseLeave:()=>H(!1)},(0,o.createElement)("svg",{width:"15",height:"16",fill:"none",onMouseEnter:()=>D(!0),onMouseLeave:()=>D(!1)},(0,o.createElement)("path",{fill:N?F:_,fillRule:"evenodd",d:"M11.856 10.847l2.883 2.883a.89.89 0 0 1 0 1.257c-.173.174-.401.261-.629.261s-.455-.087-.629-.261l-2.883-2.883c-1.144.874-2.532 1.353-3.996 1.353a6.56 6.56 0 0 1-4.671-1.935c-2.576-2.575-2.576-6.765 0-9.341C3.179.934 4.839.247 6.603.247s3.424.687 4.671 1.935a6.56 6.56 0 0 1 1.935 4.67 6.55 6.55 0 0 1-1.353 3.995zM3.189 3.439c-1.882 1.882-1.882 4.945 0 6.827.912.912 2.124 1.414 3.414 1.414s2.502-.502 3.414-1.414 1.414-2.124 1.414-3.413-.502-2.502-1.414-3.413-2.124-1.414-3.414-1.414-2.502.502-3.414 1.414z"})))),E&&(0,o.createElement)("div",{className:"backdrop"})))},icon:(0,o.createElement)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},(0,o.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.91421 1.5H5.5C4.39543 1.5 3.5 2.39543 3.5 3.5V6.91421V9.02779V15.5C3.5 16.6046 4.39543 17.5 5.5 17.5H7.02779C6.07771 16.4385 5.5 15.0367 5.5 13.5C5.5 10.1863 8.18629 7.5 11.5 7.5C13.0367 7.5 14.4385 8.07771 15.5 9.02779V8.5V6.91421C15.5 6.38378 15.2893 5.87507 14.9142 5.5L11.5 2.08579C11.1249 1.71071 10.6162 1.5 10.0858 1.5H8.91421ZM15.5 13.5C15.5 11.2909 13.7091 9.5 11.5 9.5C9.29086 9.5 7.5 11.2909 7.5 13.5C7.5 15.7091 9.29086 17.5 11.5 17.5C12.2414 17.5 12.9364 17.2977 13.5318 16.946L14.7929 18.2071C15.1834 18.5976 15.8166 18.5976 16.2071 18.2071C16.5976 17.8166 16.5976 17.1834 16.2071 16.7929L14.946 15.5318C15.2977 14.9364 15.5 14.2414 15.5 13.5ZM11.5 11.5C12.6046 11.5 13.5 12.3954 13.5 13.5C13.5 14.0526 13.2772 14.5512 12.9142 14.9142C12.5512 15.2772 12.0526 15.5 11.5 15.5C10.3954 15.5 9.5 14.6046 9.5 13.5C9.5 12.3954 10.3954 11.5 11.5 11.5Z",fill:"#111827"})),title:(0,n.__)("weDocs - Searchbar","wedocs"),keywords:["Search","weDocs search bar","Bar"],category:"widgets",description:(0,n.__)("Simple search forms for easy user guidance for your documentation","wedocs")});const h=({attributes:e,setAttributes:t})=>{const l=e=>l=>{t({[e]:l})},a=((0,n.__)("Solid","wedocs"),(0,n.__)("Dashed","wedocs"),(0,n.__)("Dotted","wedocs"),(0,n.__)("None","wedocs"),[{name:"Sweet",color:"#F43F5E"},{name:"Orange",color:"#F97316"},{name:"Yellow",color:"#FACC15"},{name:"Purple",color:"#8B5CF6"},{name:"Light Blue",color:"#3B82F6"},{name:"Light Green",color:"#10B981"}]);return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Grid Styles","wedocs"),icon:"admin-appearance",initialOpen:!1},(0,o.createElement)("label",null,(0,n.__)("Colors","wedocs")),(0,o.createElement)(u.PanelColorSettings,{colors:a,colorSettings:[{value:e.docTitleColor,label:(0,n.__)("Doc Title Color","wedocs"),onChange:e=>l("docTitleColor")(e)},{value:e.docChildrenActiveColor,label:(0,n.__)("Doc Children Active Color","wedocs"),onChange:e=>l("docChildrenActiveColor")(e)},{value:e.borderColor,label:(0,n.__)("Border Color","wedocs"),onChange:e=>l("borderColor")(e)}]}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Grid Padding","wedocs"),values:e.gridPadding,onChange:l("gridPadding")}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Grid Margin","wedocs"),values:e.gridMargin,onChange:l("gridMargin")}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Border Type","wedocs"),value:e.borderType,options:[{label:(0,n.__)("Solid","wedocs"),value:"solid"},{label:(0,n.__)("Dashed","wedocs"),value:"dashed"},{label:(0,n.__)("Dotted","wedocs"),value:"dotted"},{label:(0,n.__)("None","wedocs"),value:"none"}],onChange:e=>t({borderType:e})}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Border Width","wedocs"),value:e.borderWidth,options:[{label:"0px",value:"0px"},{label:"1px",value:"1px"},{label:"2px",value:"2px"},{label:"3px",value:"3px"},{label:"4px",value:"4px"},{label:"5px",value:"5px"}],onChange:e=>t({borderWidth:e})}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Border Radius","wedocs"),value:e.borderRadius,options:[{label:"0px",value:"0px"},{label:"4px",value:"4px"},{label:"8px",value:"8px"},{label:"12px",value:"12px"},{label:"16px",value:"16px"},{label:"20px",value:"20px"}],onChange:e=>t({borderRadius:e})})),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Button Styles","wedocs"),icon:"admin-appearance",initialOpen:!1},(0,o.createElement)("label",null,(0,n.__)("Button Colors","wedocs")),(0,o.createElement)(u.PanelColorSettings,{colors:a,colorSettings:[{value:e.buttonColor,label:(0,n.__)("Button Color","wedocs"),onChange:e=>l("buttonColor")(e)},{value:e.buttonHoverColor,label:(0,n.__)("Button Hover Color","wedocs"),onChange:e=>l("buttonHoverColor")(e)},{value:e.buttonTextColor,label:(0,n.__)("Button Text Color","wedocs"),onChange:e=>l("buttonTextColor")(e)},{value:e.buttonHoverTextColor,label:(0,n.__)("Button Hover Text Color","wedocs"),onChange:e=>l("buttonHoverTextColor")(e)}]}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Button Padding","wedocs"),values:e.buttonPadding,onChange:l("buttonPadding")}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Button Margin","wedocs"),values:e.buttonMargin,onChange:l("buttonMargin")}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Button Border Radius","wedocs"),value:e.buttonBorderRadius,options:[{label:"0px",value:"0px"},{label:"4px",value:"4px"},{label:"8px",value:"8px"},{label:"12px",value:"12px"},{label:"16px",value:"16px"},{label:"20px",value:"20px"}],onChange:e=>t({buttonBorderRadius:e})}),(0,o.createElement)("div",{className:"wedocs-color-control"},(0,o.createElement)("label",null,(0,n.__)("Button Text","wedocs")),(0,o.createElement)(m.TextControl,{value:e.buttonText,onChange:l("buttonText")}))))},_=JSON.parse('{"UU":"wedocs/wedocs-docs-grid"}');(0,a.registerBlockType)(_.UU,{edit:({attributes:e,setAttributes:t})=>{const l=(0,u.useBlockProps)(),{useSelect:a}=wp.data,[r,i]=(0,s.useState)(1),[c,p]=(0,s.useState)(!1),{hideDocGrid:g,docStyle:b,docsPerPage:_,excludeDocs:v,order:C,orderBy:w,sectionsPerDoc:E,articlesPerSection:x,showDocArticle:f,keepArticlesCollapsed:y,showViewDetails:B,gridPadding:S,gridMargin:k,docTitleColor:P,docChildrenActiveColor:T,borderType:F,borderRadius:R,borderWidth:$,borderColor:M,buttonBorderRadius:O,buttonPadding:N,buttonMargin:D,buttonColor:z,buttonHoverColor:H,buttonTextColor:A,buttonText:L,buttonHoverTextColor:W}=e,I=[{label:"All",value:"all"},...Array.from({length:10},((e,t)=>({label:String(t+1),value:String(t+1)})))],j=[{label:(0,n.__)("weDocs Order","wedocs"),value:"menu_order"},{label:(0,n.__)("ID","wedocs"),value:"id"},{label:(0,n.__)("Name","wedocs"),value:"title"}],V=[{label:(0,n.__)("Ascending","wedocs"),value:"asc"},{label:(0,n.__)("Descending","wedocs"),value:"desc"}],U=[{label:"All",value:"all"},...Array.from({length:10},((e,t)=>({label:String(t+1),value:String(t+1)})))],{pages:G,sections:Y,articles:Z}=a((e=>{const{getEntityRecords:t}=e("core"),l=t("postType","docs",{status:"publish",per_page:-1,parent:0,orderby:w,order:C}),o=l?t("postType","docs",{status:"publish",parent_in:l.map((e=>e.id)),per_page:-1}):null,a=o?t("postType","docs",{status:"publish",parent_in:o.map((e=>e.id)),per_page:-1}):null;return{pages:l,sections:o,articles:a}}),[w,C]),J=(e=>{if("all"===_)return e;const t=parseInt(_),l=(r-1)*t,o=l+t;return e.slice(l,o)})((()=>{if(!G||!Y||!Z)return[];let e=[...G];return v&&v.length>0&&(e=e.filter((e=>!v.includes(e.id.toString())))),e=e.map((e=>{let t=Y.filter((t=>t.parent===e.id));"all"!==E&&(t=t.slice(0,parseInt(E))),t=t.map((e=>{let t=Z.filter((t=>t.parent===e.id));return"all"!==x&&(t=t.slice(0,parseInt(x))),{...e,articles:t}}));const l=t.reduce(((e,t)=>e+t.articles.length),0);return{...e,sections:t,articleCount:l}})),e})()),q=G?G.reduce(((e,t)=>(e[t.id]=t.title.rendered,e)),{}):{},K=(G&&G.map((e=>({value:e.id.toString(),label:e.title.rendered}))),e=>l=>{t({[e]:l})}),Q=v?v.map((e=>q[e]||e)):[];return(0,o.createElement)(s.Fragment,null,(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Doc Grid Settings","wedocs"),icon:d,initialOpen:!1},(0,o.createElement)(m.SelectControl,{value:b,options:[{label:"1x1",value:"1x1"},{label:"1x2",value:"1x2"}],label:(0,n.__)("DOCS GRID COLUMN STYLE","wedocs"),onChange:K("docStyle")}),(0,o.createElement)(m.SelectControl,{value:_,options:I,label:(0,n.__)("Docs per page","wedocs"),onChange:K("docsPerPage")}),(0,o.createElement)(m.FormTokenField,{value:Q,suggestions:Object.values(q),label:(0,n.__)("Exclude Docs","wedocs"),onChange:e=>{const l=e.map((e=>{const t=Object.entries(q).find((([t,l])=>l===e));return t?t[0]:e}));t({excludeDocs:l})}}),(0,o.createElement)(m.SelectControl,{value:C,options:V,label:(0,n.__)("Order","wedocs"),onChange:K("order")}),(0,o.createElement)(m.SelectControl,{value:w,options:j,label:(0,n.__)("Order by","wedocs"),onChange:K("orderBy")}),(0,o.createElement)(m.SelectControl,{value:E,options:U,label:(0,n.__)("Sections per doc","wedocs"),onChange:K("sectionsPerDoc")}),(0,o.createElement)(m.SelectControl,{value:x,options:U,label:(0,n.__)("Articles per section","wedocs"),onChange:K("articlesPerSection")}),(0,o.createElement)(m.PanelRow,null,(0,o.createElement)(m.ToggleControl,{checked:f,label:(0,n.__)("Show Doc Article","wedocs"),onChange:K("showDocArticle")})),(0,o.createElement)(m.PanelRow,null,(0,o.createElement)(m.ToggleControl,{checked:y,label:(0,n.__)("Keep Article Collapsed","wedocs"),onChange:K("keepArticlesCollapsed")})),(0,o.createElement)(m.PanelRow,null,(0,o.createElement)(m.ToggleControl,{checked:B,label:(0,n.__)("Show View Details Button","wedocs"),onChange:K("showViewDetails")})))),(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(h,{attributes:e,setAttributes:t})),(0,o.createElement)("div",{...l},g?(0,o.createElement)("div",{className:"backdrop"}):(0,o.createElement)("div",{className:"wedocs-block-wrapper"},(0,o.createElement)("div",{className:`wedocs-docs-grid wedocs-docs-grid--${b}`},c?(0,o.createElement)(Spinner,null):J.map((e=>((e,t)=>(0,o.createElement)("div",{key:e.id,className:"wedocs-docs-grid__item",style:t.item},(0,o.createElement)("h3",{className:"wedocs-docs-grid__title",style:t.title},e.title.rendered),((e,t)=>e.sections?(0,o.createElement)("div",{className:"wedocs-docs-grid__sections "+(y?"is-collapsed":"")},e.sections.map((e=>(0,o.createElement)("div",{key:e.id,className:"wedocs-docs-grid__section"},(0,o.createElement)("h4",{className:"wedocs-docs-grid__section-title",style:{...t.title,display:"flex",justifyContent:"space-between",alignItems:"center"}},(0,o.createElement)("span",null,e.title.rendered),f&&e.articles&&e.articles.length>0&&(0,o.createElement)("svg",{fill:"none",viewBox:"0 0 24 24",width:"16",strokeWidth:"2",stroke:"#acb8c4",className:y?"":"active"},(0,o.createElement)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"}))),f&&!y&&e.articles&&(0,o.createElement)("ul",{className:"wedocs-docs-grid__articles"},e.articles.map((e=>(0,o.createElement)("li",{key:e.id,className:"wedocs-docs-grid__article",style:t.children},e.title.rendered))))))),0===e.sections.length&&(0,o.createElement)("span",{className:"inside"},(0,o.createElement)("svg",{fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},(0,o.createElement)("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"})),(0,n.__)("This document has no sections yet. Check back later or wait for the author to add content.","wedocs"))):null)(e,t),B&&(0,o.createElement)("div",{className:"wedocs-docs-grid__details"},(0,o.createElement)("span",{className:"wedocs-docs-grid__details-link",style:t.button},t.button.text))))(e,(()=>{const e=S?`${S.top} ${S.right} ${S.bottom} ${S.left}`:"",t=k?`${k.top} ${k.right} ${k.bottom} ${k.left}`:"",l=N?`${N.top} ${N.right} ${N.bottom} ${N.left}`:"",o=O||"8px",a=D?`${D.top} ${D.right} ${D.bottom} ${D.left}`:"";return{item:{padding:e,margin:t,borderStyle:F||"solid",borderWidth:$||"1px",borderColor:M||"rgba(0, 0, 0, 0.1)",borderRadius:R||"8px",backgroundColor:"#fff"},title:{color:P||"#1e1e1e"},children:{color:T||"#0073aa"},button:{padding:l,margin:a,backgroundColor:z||"#0073aa",color:A||"#ffffff",text:L||(0,n.__)("View Details","wedocs"),borderRadius:o||"8px","--hover-bg":H||"#005177","--hover-color":W||"#ffffff"}}})())))))))},save:()=>null});const v=({attributes:e,setAttributes:t})=>{const{padding:l,margin:a,backgroundColor:r,textColor:i,hoverBackgroundColor:c,hoverTextColor:d,borderRadius:p,borderWidth:g,borderColor:b,borderStyle:h,fontSize:_,fontWeight:v}=e,C=(l,o=null)=>a=>{t(o?{[l]:{...e[l],[o]:a}}:{[l]:a})};return(0,o.createElement)(s.Fragment,null,(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Style Settings","wedocs"),initialOpen:!1},(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Button Style","wedocs"),value:e.buttonStyle,options:[{label:(0,n.__)("Primary","wedocs"),value:"primary"},{label:(0,n.__)("Secondary","wedocs"),value:"secondary"},{label:(0,n.__)("Outline","wedocs"),value:"outline"},{label:(0,n.__)("Ghost","wedocs"),value:"ghost"}],onChange:C("buttonStyle")}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Button Size","wedocs"),value:e.buttonSize,options:[{label:(0,n.__)("Small","wedocs"),value:"small"},{label:(0,n.__)("Medium","wedocs"),value:"medium"},{label:(0,n.__)("Large","wedocs"),value:"large"}],onChange:C("buttonSize")}),(0,o.createElement)(u.PanelColorSettings,{title:(0,n.__)("Color Settings","wedocs"),initialOpen:!1,colorSettings:[{value:i,onChange:C("textColor"),label:(0,n.__)("Text Color","wedocs")},{value:r,onChange:C("backgroundColor"),label:(0,n.__)("Background Color","wedocs")}]}),(0,o.createElement)(u.PanelColorSettings,{title:(0,n.__)("Hover Color Settings","wedocs"),initialOpen:!1,colorSettings:[{value:d,onChange:C("hoverTextColor"),label:(0,n.__)("Hover Text Color","wedocs")},{value:c,onChange:C("hoverBackgroundColor"),label:(0,n.__)("Hover Background Color","wedocs")}]})),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Spacing","wedocs"),initialOpen:!1},m.__experimentalBoxControl?(0,o.createElement)(s.Fragment,null,(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Padding","wedocs"),values:l,onChange:C("padding"),units:[{value:"px",label:"px",default:0},{value:"em",label:"em",default:0},{value:"%",label:"%",default:0}]}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Margin","wedocs"),values:a,onChange:C("margin"),units:[{value:"px",label:"px",default:0},{value:"em",label:"em",default:0},{value:"%",label:"%",default:0}]})):(0,o.createElement)(s.Fragment,null,(0,o.createElement)("p",{style:{marginBottom:"16px",color:"#666"}},(0,n.__)("Individual spacing controls (Padding & Margin)","wedocs")),(0,o.createElement)("div",{style:{marginBottom:"16px"}},(0,o.createElement)("strong",null,(0,n.__)("Padding","wedocs"))),(0,o.createElement)("div",{style:{marginBottom:"16px"}},(0,o.createElement)("strong",null,(0,n.__)("Margin","wedocs"))))),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Border & Typography","wedocs"),initialOpen:!1},m.__experimentalUnitControl?(0,o.createElement)(s.Fragment,null,(0,o.createElement)(m.__experimentalUnitControl,{label:(0,n.__)("Border Radius","wedocs"),value:p,onChange:C("borderRadius"),units:[{value:"px",label:"px",default:0},{value:"em",label:"em",default:0},{value:"%",label:"%",default:0}]}),(0,o.createElement)(m.__experimentalUnitControl,{label:(0,n.__)("Border Width","wedocs"),value:g,onChange:C("borderWidth"),units:[{value:"px",label:"px",default:0}]}),(0,o.createElement)(m.__experimentalUnitControl,{label:(0,n.__)("Font Size","wedocs"),value:_,onChange:C("fontSize"),units:[{value:"px",label:"px",default:16},{value:"em",label:"em",default:1},{value:"rem",label:"rem",default:1}]})):(0,o.createElement)(s.Fragment,null,(0,o.createElement)(m.RangeControl,{label:(0,n.__)("Border Radius (px)","wedocs"),value:parseInt(p),onChange:e=>C("borderRadius")(`${e}px`),min:0,max:50}),(0,o.createElement)(m.RangeControl,{label:(0,n.__)("Border Width (px)","wedocs"),value:parseInt(g),onChange:e=>C("borderWidth")(`${e}px`),min:0,max:10}),(0,o.createElement)(m.RangeControl,{label:(0,n.__)("Font Size (px)","wedocs"),value:parseInt(_),onChange:e=>C("fontSize")(`${e}px`),min:10,max:32})),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Border Style","wedocs"),value:h,options:[{label:(0,n.__)("Solid","wedocs"),value:"solid"},{label:(0,n.__)("Dashed","wedocs"),value:"dashed"},{label:(0,n.__)("Dotted","wedocs"),value:"dotted"},{label:(0,n.__)("None","wedocs"),value:"none"}],onChange:C("borderStyle")}),(0,o.createElement)(u.PanelColorSettings,{title:(0,n.__)("Border Color","wedocs"),initialOpen:!1,colorSettings:[{value:b,onChange:C("borderColor"),label:(0,n.__)("Border Color","wedocs")}]}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Font Weight","wedocs"),value:v,options:[{label:(0,n.__)("Normal","wedocs"),value:"normal"},{label:(0,n.__)("Bold","wedocs"),value:"bold"},{label:(0,n.__)("Light","wedocs"),value:"300"},{label:(0,n.__)("Medium","wedocs"),value:"500"},{label:(0,n.__)("Semi Bold","wedocs"),value:"600"},{label:(0,n.__)("Extra Bold","wedocs"),value:"800"}],onChange:C("fontWeight")}))))},C=JSON.parse('{"UU":"wedocs/print-button"}');(0,a.registerBlockType)(C.UU,{edit:({attributes:e,setAttributes:t})=>{const l=(0,u.useBlockProps)(),{layout:a,alignment:r,buttonText:i,showIcon:c,padding:d,margin:p,backgroundColor:g,textColor:b,hoverBackgroundColor:h,hoverTextColor:_,borderRadius:C,borderWidth:w,borderColor:E,borderStyle:x,fontSize:f,fontWeight:y,additionalClasses:B}=e,S={display:"inline-flex",alignItems:"center",justifyContent:"center",gap:c?"8px":"0",padding:`${d.top} ${d.right} ${d.bottom} ${d.left}`,margin:`${p.top} ${p.right} ${p.bottom} ${p.left}`,backgroundColor:g,color:b,border:`${w} ${x} ${E}`,borderRadius:C,fontSize:f,fontWeight:y,textDecoration:"none",cursor:"pointer",transition:"all 0.2s ease-in-out","--hover-bg-color":h,"--hover-text-color":_},k={textAlign:r,width:"100%"};return(0,o.createElement)(s.Fragment,null,(0,o.createElement)(u.BlockControls,null,(0,o.createElement)(u.AlignmentToolbar,{value:r,onChange:e=>t({alignment:e||"left"})})),(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("General Settings","wedocs"),initialOpen:!0},(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Layout","wedocs"),value:a,options:[{label:(0,n.__)("Layout 1 - Horizontal","wedocs"),value:"layout1"},{label:(0,n.__)("Layout 2 - Button Style","wedocs"),value:"layout2"},{label:(0,n.__)("Layout 3 - Vertical","wedocs"),value:"layout3"}],onChange:e=>t({layout:e})}),(0,o.createElement)(m.TextControl,{label:(0,n.__)("Button Text","wedocs"),value:i,onChange:e=>t({buttonText:e}),placeholder:(0,n.__)("Print","wedocs")}),(0,o.createElement)(m.PanelRow,null,(0,o.createElement)(m.ToggleControl,{label:(0,n.__)("Show Print Icon","wedocs"),checked:c,onChange:e=>t({showIcon:e})}))),(0,o.createElement)(v,{attributes:e,setAttributes:t}),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Advanced","wedocs"),initialOpen:!1},(0,o.createElement)(m.TextControl,{label:(0,n.__)("Additional CSS Classes","wedocs"),value:B,onChange:e=>t({additionalClasses:e}),help:(0,n.__)("Add custom CSS classes separated by spaces","wedocs")}))),(0,o.createElement)("div",{...l},(0,o.createElement)("div",{className:"wedocs-print-button-wrapper"},(()=>{switch(a){case"layout2":return(0,o.createElement)("div",{style:k},(0,o.createElement)("button",{className:`wedocs-print-button layout-2 ${B}`,style:S,onClick:e=>e.preventDefault()},c&&(0,o.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},(0,o.createElement)("path",{d:"M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"})),(0,o.createElement)("span",null,i||(0,n.__)("Print","wedocs"))));case"layout3":return(0,o.createElement)("div",{style:k},(0,o.createElement)("button",{className:`wedocs-print-button layout-3 ${B}`,style:{...S,flexDirection:"column",gap:"4px"},onClick:e=>e.preventDefault()},c&&(0,o.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},(0,o.createElement)("path",{d:"M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"})),(0,o.createElement)("span",{style:{fontSize:"12px"}},i||(0,n.__)("Print","wedocs"))));default:return(0,o.createElement)("div",{style:k},(0,o.createElement)("button",{className:`wedocs-print-button layout-1 ${B}`,style:S,onClick:e=>e.preventDefault()},c&&(0,o.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},(0,o.createElement)("path",{d:"M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"})),(0,o.createElement)("span",null,i||(0,n.__)("Print","wedocs"))))}})())))}})},609:e=>{e.exports=window.React}},l={};function o(e){var a=l[e];if(void 0!==a)return a.exports;var n=l[e]={exports:{}};return t[e](n,n.exports,o),n.exports}o.m=t,e=[],o.O=(t,l,a,n)=>{if(!l){var r=1/0;for(s=0;s<e.length;s++){l=e[s][0],a=e[s][1],n=e[s][2];for(var i=!0,c=0;c<l.length;c++)(!1&n||r>=n)&&Object.keys(o.O).every((e=>o.O[e](l[c])))?l.splice(c--,1):(i=!1,n<r&&(r=n));if(i){e.splice(s--,1);var d=a();void 0!==d&&(t=d)}}return t}n=n||0;for(var s=e.length;s>0&&e[s-1][2]>n;s--)e[s]=e[s-1];e[s]=[l,a,n]},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={366:0,337:0};o.O.j=t=>0===e[t];var t=(t,l)=>{var a,n,r=l[0],i=l[1],c=l[2],d=0;if(r.some((t=>0!==e[t]))){for(a in i)o.o(i,a)&&(o.m[a]=i[a]);if(c)var s=c(o)}for(t&&t(l);d<r.length;d++)n=r[d],o.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return o.O(s)},l=self.webpackChunkweDocs=self.webpackChunkweDocs||[];l.forEach(t.bind(null,0)),l.push=t.bind(null,l.push.bind(l))})();var a=o.O(void 0,[337],(()=>o(870)));a=o.O(a)})(); No newline at end of file | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Fix ReferenceError: global weDocsBlockVars is not defined (breaks search block save).
The bundle references weDocsBlockVars?.siteUrl inside wedocs/wedocs-search save(). Optional chaining does not guard an undeclared global, so this will throw at runtime if the var isn't registered. Use window.weDocs_Vars?.siteUrl (matches the rest of the plugin) or guard via typeof.
Apply in source (not in built file), then rebuild:
- action: weDocsBlockVars?.siteUrl,
+ action: ( typeof window !== 'undefined' && window.weDocs_Vars && window.weDocs_Vars.siteUrl ) ? window.weDocs_Vars.siteUrl : '/',Run to confirm no remaining occurrences:
🏁 Script executed:
#!/bin/bash
rg -nP '\bweDocsBlockVars\b' -SLength of output: 34369
Fix ReferenceError: guard weDocsBlockVars in Search block save
src/blocks/Search/save.js uses weDocsBlockVars?.siteUrl — optional chaining on an undeclared identifier throws at runtime. Update the source (not the built file), rebuild, and verify.
Location: src/blocks/Search/save.js (around line 70). Built occurrence: assets/build/block.js. Registered in PHP: includes/Assets.php:94.
Suggested change:
- action: weDocsBlockVars?.siteUrl,
+ action: (typeof window !== 'undefined' && window.weDocsBlockVars && window.weDocsBlockVars.siteUrl) ? window.weDocsBlockVars.siteUrl : '/',Apply in source, rebuild assets, then confirm no remaining occurrences:
rg -nP '\bweDocsBlockVars\b' -S🧰 Tools
🪛 Biome (2.1.2)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
🤖 Prompt for AI Agents
assets/build/block.js (built occurrence) and source file
src/blocks/Search/save.js around line ~70: the save implementation uses
weDocsBlockVars?.siteUrl which triggers a ReferenceError at runtime because
weDocsBlockVars is not declared in some contexts; update the source file (not
the built file) to guard access by referencing a safe global (e.g., use typeof
weDocsBlockVars !== "undefined" ? weDocsBlockVars.siteUrl : undefined or
window?.weDocsBlockVars?.siteUrl) so optional-chaining is only used on a defined
identifier, rebuild the assets, and verify the identifier no longer appears in
built output and in PHP registration (includes/Assets.php:94) by running the
suggested ripgrep command.
🧩 Analysis chain
Fix undefined Spinner usage (use wp.components.Spinner).
In the docs grid editor render path the code calls Spinner unqualified; it should be m.Spinner (const m = window.wp.components). This will error if that branch is hit.
Suggested source fix before build:
- c ? (0,o.createElement)(Spinner,null) : J.map( ... )
+ c ? (0,o.createElement)(m.Spinner,null) : J.map( ... )Verify:
🏁 Script executed:
#!/bin/bash
rg -nP '\bSpinner\b(?!\s*[:,.])' -g '!assets/build/**'Length of output: 83
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Searching for literal 'Spinner' occurrences (including assets/build)..."
rg -nF --hidden --no-ignore 'Spinner' || true
echo
echo "Searching for 'm = window.wp.components' mapping (literal)..."
rg -nF --hidden --no-ignore 'm=window.wp.components' || true
rg -nF --hidden --no-ignore 'm = window.wp.components' || true
if [ -f assets/build/block.js ]; then
echo
echo "Matches with context in assets/build/block.js:"
rg -nF -C3 'Spinner' assets/build/block.js || true
echo
echo "Showing lines 1-220 of assets/build/block.js for context:"
nl -ba assets/build/block.js | sed -n '1,220p'
else
echo "assets/build/block.js not found"
fiLength of output: 103032
Fix undefined Spinner usage — import Spinner or call wp.components.Spinner
assets/build/block.js contains an unqualified Spinner (assets/build/block.js:1) and the source uses (src/blocks/DocsGrid/edit.js:534). This will throw at runtime when the loading branch runs.
- Preferred fix (edit source): add the Spinner import to src/blocks/DocsGrid/edit.js:
+ import { Spinner } from '@wordpress/components';- Quick alternative (patch built asset, not recommended): replace unqualified Spinner with m.Spinner:
- c ? (0,o.createElement)(Spinner,null) : J.map( ... )
+ c ? (0,o.createElement)(m.Spinner,null) : J.map( ... )📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| (()=>{"use strict";var e,t={418:(e,t,l)=>{var o=l(609),a=Symbol.for("react.element"),n=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),r=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,l){var o,c={},d=null,s=null;for(o in void 0!==l&&(d=""+l),void 0!==t.key&&(d=""+t.key),void 0!==t.ref&&(s=t.ref),t)n.call(t,o)&&!i.hasOwnProperty(o)&&(c[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===c[o]&&(c[o]=t[o]);return{$$typeof:a,type:e,key:d,ref:s,props:c,_owner:r.current}}},706:(e,t,l)=>{e.exports=l(418)},870:(e,t,l)=>{var o=l(609);const a=window.wp.blocks,n=window.wp.i18n,r=window.wp.primitives;var i=l(706);const c=(0,i.jsx)(r.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(r.Path,{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6.5c-1.4 0-2.5-1.1-2.5-2.5s1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5-1.1 2.5-2.5 2.5zM12.8 3h-1.5v3h1.5V3zm-1.6 18h1.5v-3h-1.5v3zm6.8-9.8v1.5h3v-1.5h-3zm-12 0H3v1.5h3v-1.5zm9.7 5.6 2.1 2.1 1.1-1.1-2.1-2.1-1.1 1.1zM8.3 7.2 6.2 5.1 5.1 6.2l2.1 2.1 1.1-1.1zM5.1 17.8l1.1 1.1 2.1-2.1-1.1-1.1-2.1 2.1zM18.9 6.2l-1.1-1.1-2.1 2.1 1.1 1.1 2.1-2.1z"})}),d=(0,i.jsx)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(r.Path,{fillRule:"evenodd",d:"M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z",clipRule:"evenodd"})}),s=window.wp.element,u=window.wp.blockEditor,m=window.wp.components,p=({label:e,value:t,unit:l,onValueChange:a,onUnitChange:r})=>(0,o.createElement)(m.Flex,null,(0,o.createElement)(m.FlexBlock,null,(0,o.createElement)(m.TextControl,{label:e,value:parseInt(t),onChange:e=>a(e)})),(0,o.createElement)(m.FlexItem,null,(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Unit","wedocs"),value:l,options:[{label:"px",value:"px"},{label:"%",value:"%"}],onChange:e=>r(e)}))),g=({selected:e,options:t,onChange:l})=>(0,o.createElement)(m.BaseControl,null,(0,o.createElement)("div",{className:"radio-image-control-options"},t.map((t=>(0,o.createElement)("div",{key:t.value,className:"radio-image-option"},(0,o.createElement)("input",{type:"radio",id:`radio-image-${t.value}`,value:t.value,checked:e===t.value,onChange:e=>l(e.target.value)}),(0,o.createElement)("label",{htmlFor:`radio-image-${t.value}`},t.icon&&(0,o.createElement)("i",{className:`dashicons ${t.icon}`}),t.img&&(0,o.createElement)("img",{src:t.img,alt:t.label}),t?.svg)))))),b={hideSearch:{type:"boolean",default:!1},searchWidth:{type:"number",default:50},widthUnit:{type:"string",default:"%"},placeholder:{type:"string",default:(0,n.__)("Search for a top or question","wedocs")},alignment:{type:"string",default:"right"},bgColor:{type:"string",default:"#FFFFFF"},hoverColor:{type:"string",default:"#FFFFFF"},padding:{type:"object",default:{top:14,left:22,right:22,bottom:14}},margin:{type:"object",default:{top:0,left:0,right:0,bottom:0}},borderColor:{type:"string",default:"#cccccc"},borderType:{type:"string",default:"solid"},borderWidth:{type:"number",default:1},borderRadius:{type:"number",default:30},iconColor:{type:"string",default:"#FFFFFF"},iconBgColor:{type:"string",default:"#3b82f6"},iconHoverColor:{type:"string",default:"#2563eb"},svgHoverColor:{type:"string",default:"#FFFFFF"},btnPadding:{type:"object",default:{top:24,left:26,right:26,bottom:24}},btnPosition:{type:"object",default:{top:0,right:0,bottom:10}},btnRadius:{type:"number",default:30}};(0,a.registerBlockType)("wedocs/wedocs-search",{attributes:b,save:({attributes:e})=>{const{margin:t,bgColor:l,padding:a,btnRadius:n,alignment:r,iconColor:i,widthUnit:c,hoverColor:d,borderType:m,hideSearch:p,btnPadding:g,searchWidth:b,btnPosition:h,placeholder:_,borderColor:v,borderWidth:C,iconBgColor:w,borderRadius:E,svgHoverColor:x,iconHoverColor:f}=e;if(p)return;const y={display:"flex",justifyContent:r},B={border:`${C}px ${m} ${v}`,paddingTop:a?.top,paddingLeft:a?.left,paddingRight:a?.right,borderRadius:`${E}px`,paddingBottom:a?.bottom,"--field-color":l,"--field-bg-color":d},S={top:h?.top,left:h?.left,right:h?.right,bottom:h?.bottom,height:"auto",paddingTop:g?.top,paddingLeft:g?.left,borderRadius:n,paddingRight:g?.right,paddingBottom:g?.bottom,"--field-icon-color":i,"--field-btn-bg-color":w,"--field-icon-hover-color":x,"--field-btn-bg-hover-color":f};return(0,o.createElement)(s.Fragment,null,(0,o.createElement)("form",{method:"get",role:"search",action:weDocsBlockVars?.siteUrl,...u.useBlockProps.save({className:"search-form wedocs-search-form"})},(0,o.createElement)("div",{style:y},(0,o.createElement)("div",{className:"wedocs-search-input",style:{width:b+c,marginTop:t?.top,marginLeft:t?.left,marginRight:t?.right,marginBottom:t?.bottom}},(0,o.createElement)("input",{name:"s",type:"search",style:B,className:"search-field",placeholder:_}),(0,o.createElement)("input",{type:"hidden",name:"post_type",value:"docs"}),(0,o.createElement)("button",{type:"submit",style:S,className:"search-submit"},(0,o.createElement)("svg",{width:"15",height:"16",fill:"none"},(0,o.createElement)("path",{fillRule:"evenodd",d:"M11.856 10.847l2.883 2.883a.89.89 0 0 1 0 1.257c-.173.174-.401.261-.629.261s-.455-.087-.629-.261l-2.883-2.883c-1.144.874-2.532 1.353-3.996 1.353a6.56 6.56 0 0 1-4.671-1.935c-2.576-2.575-2.576-6.765 0-9.341C3.179.934 4.839.247 6.603.247s3.424.687 4.671 1.935a6.56 6.56 0 0 1 1.935 4.67 6.55 6.55 0 0 1-1.353 3.995zM3.189 3.439c-1.882 1.882-1.882 4.945 0 6.827.912.912 2.124 1.414 3.414 1.414s2.502-.502 3.414-1.414 1.414-2.124 1.414-3.413-.502-2.502-1.414-3.413-2.124-1.414-3.414-1.414-2.502.502-3.414 1.414z"})))))))},edit:({attributes:e,setAttributes:t})=>{const l=(0,u.useBlockProps)(),{margin:a,bgColor:r,padding:i,btnRadius:b,alignment:h,iconColor:_,widthUnit:v,hoverColor:C,borderType:w,hideSearch:E,btnPadding:x,searchWidth:f,btnPosition:y,placeholder:B,borderColor:S,borderWidth:k,iconBgColor:P,borderRadius:T,svgHoverColor:F,iconHoverColor:R}=e;console.log("editor panel:",r);const $=[{value:"left",label:(0,n.__)("Align left","wedocs"),svg:(0,o.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"left"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,o.createElement)("path",{d:"M8 9.462h12m-12 6h6m-10-9v12"}))},{value:"center",label:(0,n.__)("Align center","wedocs"),svg:(0,o.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"center"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,o.createElement)("path",{d:"M18 9.462H6m8.99 6h-6"}),(0,o.createElement)("path",{d:"M12 6.462v12"}))},{value:"right",label:(0,n.__)("Align right","wedocs"),svg:(0,o.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"right"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,o.createElement)("path",{d:"M16 9.462H4m12 6h-6m10-9v12"}))}],[M,O]=(0,s.useState)(!1),[N,D]=(0,s.useState)(!1),[z,H]=(0,s.useState)(!1),A={display:"flex",justifyContent:h},L={border:`${k}px ${w} ${S}`,paddingTop:i?.top,background:M?C:r,paddingLeft:i?.left,paddingRight:i?.right,borderRadius:`${T}px`,paddingBottom:i?.bottom},W={top:y?.top,left:y?.left,right:y?.right,bottom:y?.bottom,height:"auto",background:z?R:P,paddingTop:x?.top,paddingLeft:x?.left,borderRadius:b,paddingRight:x?.right,paddingBottom:x?.bottom},I=[{label:(0,n.__)("Solid","wedocs"),value:"solid"},{label:(0,n.__)("Dotted","wedocs"),value:"dotted"},{label:(0,n.__)("Dashed","wedocs"),value:"dashed"},{label:(0,n.__)("Double","wedocs"),value:"double"},{label:(0,n.__)("Groove","wedocs"),value:"groove"},{label:(0,n.__)("Ridge","wedocs"),value:"ridge"},{label:(0,n.__)("Inset","wedocs"),value:"inset"},{label:(0,n.__)("Outset","wedocs"),value:"outset"},{label:(0,n.__)("None","wedocs"),value:"none"},{label:(0,n.__)("Hidden","wedocs"),value:"hidden"}];return(0,o.createElement)(s.Fragment,null,(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(m.PanelBody,null,(0,o.createElement)(m.ToggleControl,{checked:E,className:"wedocs-search-toggle",label:(0,n.__)("Disable Block","wedocs"),onChange:e=>t({hideSearch:e})})),!E&&(0,o.createElement)(s.Fragment,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Color Settings","wedocs"),icon:c,initialOpen:!1,className:"wedocs-search-color-settings"},(0,o.createElement)(u.PanelColorSettings,{colors:[{name:"Sweet",color:"#F43F5E"},{name:"Orange",color:"#F97316"},{name:"Yellow",color:"#FACC15"},{name:"Purple",color:"#8B5CF6"},{name:"Light Blue",color:"#3B82F6"},{name:"Light Green",color:"#10B981"}],colorSettings:[{value:r,label:(0,n.__)("Field Background Color","wedocs"),onChange:e=>t({bgColor:e})},{value:C,label:(0,n.__)("Field Hover Color","wedocs"),onChange:e=>t({hoverColor:e})},{value:S,label:(0,n.__)("Border Color","wedocs"),onChange:e=>t({borderColor:e})},{value:_,label:(0,n.__)("Icon Color","wedocs"),onChange:e=>t({iconColor:e})},{value:P,label:(0,n.__)("Button Color","wedocs"),onChange:e=>t({iconBgColor:e})},{value:R,label:(0,n.__)("Button Hover Color","wedocs"),onChange:e=>t({iconHoverColor:e})},{value:F,label:(0,n.__)("Icon Hover Color","wedocs"),onChange:e=>t({svgHoverColor:e})}]})),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Search Bar Settings","wedocs"),icon:d},(0,o.createElement)(p,{unit:v,value:f,label:(0,n.__)("Field Width","wedocs"),onUnitChange:e=>t({widthUnit:e}),onValueChange:e=>t({searchWidth:e?parseInt(e):0})}),(0,o.createElement)(m.TextControl,{value:B,label:(0,n.__)("Placeholder","wedocs"),placeholder:(0,n.__)("Search bar placeholder","wedocs"),onChange:e=>t({placeholder:e})}),(0,o.createElement)("p",{style:{fontSize:11}},(0,n.__)("POSITION","wedocs")),(0,o.createElement)(g,{selected:h,options:$,onChange:e=>t({alignment:e})}),(0,o.createElement)(m.__experimentalBoxControl,{resetValues:{top:"14px",left:"22px",right:"22px",bottom:"14px"},values:i,label:(0,n.__)("Field Padding","wedocs"),onChange:e=>t({padding:e})}),(0,o.createElement)(m.__experimentalBoxControl,{resetValues:{top:"0px",left:"0px",right:"0px",bottom:"0px"},values:a,label:(0,n.__)("Field Margin","wedocs"),onChange:e=>t({margin:e})}),(0,o.createElement)(m.RangeControl,{min:0,max:10,value:k,label:(0,n.__)("Border Width","wedocs"),onChange:e=>t({borderWidth:e})}),(0,o.createElement)(m.RangeControl,{min:0,max:100,value:T,label:(0,n.__)("Border Radius","wedocs"),onChange:e=>t({borderRadius:e})}),(0,o.createElement)(m.SelectControl,{value:w,options:I,label:(0,n.__)("Border Type","wedocs"),onChange:e=>t({borderType:e})}),(0,o.createElement)(m.__experimentalBoxControl,{resetValues:{top:"24px",left:"26px",right:"26px",bottom:"24px"},values:x,label:(0,n.__)("Button Padding","wedocs"),onChange:e=>t({btnPadding:e})}),(0,o.createElement)(m.__experimentalBoxControl,{resetValues:{top:"0px",right:"0px",bottom:"10px"},values:y,label:(0,n.__)("Button Margin","wedocs"),onChange:e=>t({btnPosition:e})}),(0,o.createElement)(m.RangeControl,{min:0,max:100,value:b,label:(0,n.__)("Button Radius","wedocs"),onChange:e=>t({btnRadius:e})})))),(0,o.createElement)("div",{...l,style:A},(0,o.createElement)("div",{className:"wedocs-editor-search-input",style:{width:f+v,marginTop:a?.top,marginLeft:a?.left,marginRight:a?.right,marginBottom:a?.bottom}},(0,o.createElement)("input",{readOnly:!0,style:L,className:"search-field",placeholder:B,onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1)}),(0,o.createElement)("input",{type:"hidden",name:"post_type",value:"docs"}),(0,o.createElement)("button",{type:"submit",style:W,className:"search-submit",onMouseEnter:()=>H(!0),onMouseLeave:()=>H(!1)},(0,o.createElement)("svg",{width:"15",height:"16",fill:"none",onMouseEnter:()=>D(!0),onMouseLeave:()=>D(!1)},(0,o.createElement)("path",{fill:N?F:_,fillRule:"evenodd",d:"M11.856 10.847l2.883 2.883a.89.89 0 0 1 0 1.257c-.173.174-.401.261-.629.261s-.455-.087-.629-.261l-2.883-2.883c-1.144.874-2.532 1.353-3.996 1.353a6.56 6.56 0 0 1-4.671-1.935c-2.576-2.575-2.576-6.765 0-9.341C3.179.934 4.839.247 6.603.247s3.424.687 4.671 1.935a6.56 6.56 0 0 1 1.935 4.67 6.55 6.55 0 0 1-1.353 3.995zM3.189 3.439c-1.882 1.882-1.882 4.945 0 6.827.912.912 2.124 1.414 3.414 1.414s2.502-.502 3.414-1.414 1.414-2.124 1.414-3.413-.502-2.502-1.414-3.413-2.124-1.414-3.414-1.414-2.502.502-3.414 1.414z"})))),E&&(0,o.createElement)("div",{className:"backdrop"})))},icon:(0,o.createElement)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},(0,o.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.91421 1.5H5.5C4.39543 1.5 3.5 2.39543 3.5 3.5V6.91421V9.02779V15.5C3.5 16.6046 4.39543 17.5 5.5 17.5H7.02779C6.07771 16.4385 5.5 15.0367 5.5 13.5C5.5 10.1863 8.18629 7.5 11.5 7.5C13.0367 7.5 14.4385 8.07771 15.5 9.02779V8.5V6.91421C15.5 6.38378 15.2893 5.87507 14.9142 5.5L11.5 2.08579C11.1249 1.71071 10.6162 1.5 10.0858 1.5H8.91421ZM15.5 13.5C15.5 11.2909 13.7091 9.5 11.5 9.5C9.29086 9.5 7.5 11.2909 7.5 13.5C7.5 15.7091 9.29086 17.5 11.5 17.5C12.2414 17.5 12.9364 17.2977 13.5318 16.946L14.7929 18.2071C15.1834 18.5976 15.8166 18.5976 16.2071 18.2071C16.5976 17.8166 16.5976 17.1834 16.2071 16.7929L14.946 15.5318C15.2977 14.9364 15.5 14.2414 15.5 13.5ZM11.5 11.5C12.6046 11.5 13.5 12.3954 13.5 13.5C13.5 14.0526 13.2772 14.5512 12.9142 14.9142C12.5512 15.2772 12.0526 15.5 11.5 15.5C10.3954 15.5 9.5 14.6046 9.5 13.5C9.5 12.3954 10.3954 11.5 11.5 11.5Z",fill:"#111827"})),title:(0,n.__)("weDocs - Searchbar","wedocs"),keywords:["Search","weDocs search bar","Bar"],category:"widgets",description:(0,n.__)("Simple search forms for easy user guidance for your documentation","wedocs")});const h=({attributes:e,setAttributes:t})=>{const l=e=>l=>{t({[e]:l})},a=((0,n.__)("Solid","wedocs"),(0,n.__)("Dashed","wedocs"),(0,n.__)("Dotted","wedocs"),(0,n.__)("None","wedocs"),[{name:"Sweet",color:"#F43F5E"},{name:"Orange",color:"#F97316"},{name:"Yellow",color:"#FACC15"},{name:"Purple",color:"#8B5CF6"},{name:"Light Blue",color:"#3B82F6"},{name:"Light Green",color:"#10B981"}]);return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Grid Styles","wedocs"),icon:"admin-appearance",initialOpen:!1},(0,o.createElement)("label",null,(0,n.__)("Colors","wedocs")),(0,o.createElement)(u.PanelColorSettings,{colors:a,colorSettings:[{value:e.docTitleColor,label:(0,n.__)("Doc Title Color","wedocs"),onChange:e=>l("docTitleColor")(e)},{value:e.docChildrenActiveColor,label:(0,n.__)("Doc Children Active Color","wedocs"),onChange:e=>l("docChildrenActiveColor")(e)},{value:e.borderColor,label:(0,n.__)("Border Color","wedocs"),onChange:e=>l("borderColor")(e)}]}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Grid Padding","wedocs"),values:e.gridPadding,onChange:l("gridPadding")}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Grid Margin","wedocs"),values:e.gridMargin,onChange:l("gridMargin")}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Border Type","wedocs"),value:e.borderType,options:[{label:(0,n.__)("Solid","wedocs"),value:"solid"},{label:(0,n.__)("Dashed","wedocs"),value:"dashed"},{label:(0,n.__)("Dotted","wedocs"),value:"dotted"},{label:(0,n.__)("None","wedocs"),value:"none"}],onChange:e=>t({borderType:e})}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Border Width","wedocs"),value:e.borderWidth,options:[{label:"0px",value:"0px"},{label:"1px",value:"1px"},{label:"2px",value:"2px"},{label:"3px",value:"3px"},{label:"4px",value:"4px"},{label:"5px",value:"5px"}],onChange:e=>t({borderWidth:e})}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Border Radius","wedocs"),value:e.borderRadius,options:[{label:"0px",value:"0px"},{label:"4px",value:"4px"},{label:"8px",value:"8px"},{label:"12px",value:"12px"},{label:"16px",value:"16px"},{label:"20px",value:"20px"}],onChange:e=>t({borderRadius:e})})),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Button Styles","wedocs"),icon:"admin-appearance",initialOpen:!1},(0,o.createElement)("label",null,(0,n.__)("Button Colors","wedocs")),(0,o.createElement)(u.PanelColorSettings,{colors:a,colorSettings:[{value:e.buttonColor,label:(0,n.__)("Button Color","wedocs"),onChange:e=>l("buttonColor")(e)},{value:e.buttonHoverColor,label:(0,n.__)("Button Hover Color","wedocs"),onChange:e=>l("buttonHoverColor")(e)},{value:e.buttonTextColor,label:(0,n.__)("Button Text Color","wedocs"),onChange:e=>l("buttonTextColor")(e)},{value:e.buttonHoverTextColor,label:(0,n.__)("Button Hover Text Color","wedocs"),onChange:e=>l("buttonHoverTextColor")(e)}]}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Button Padding","wedocs"),values:e.buttonPadding,onChange:l("buttonPadding")}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Button Margin","wedocs"),values:e.buttonMargin,onChange:l("buttonMargin")}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Button Border Radius","wedocs"),value:e.buttonBorderRadius,options:[{label:"0px",value:"0px"},{label:"4px",value:"4px"},{label:"8px",value:"8px"},{label:"12px",value:"12px"},{label:"16px",value:"16px"},{label:"20px",value:"20px"}],onChange:e=>t({buttonBorderRadius:e})}),(0,o.createElement)("div",{className:"wedocs-color-control"},(0,o.createElement)("label",null,(0,n.__)("Button Text","wedocs")),(0,o.createElement)(m.TextControl,{value:e.buttonText,onChange:l("buttonText")}))))},_=JSON.parse('{"UU":"wedocs/wedocs-docs-grid"}');(0,a.registerBlockType)(_.UU,{edit:({attributes:e,setAttributes:t})=>{const l=(0,u.useBlockProps)(),{useSelect:a}=wp.data,[r,i]=(0,s.useState)(1),[c,p]=(0,s.useState)(!1),{hideDocGrid:g,docStyle:b,docsPerPage:_,excludeDocs:v,order:C,orderBy:w,sectionsPerDoc:E,articlesPerSection:x,showDocArticle:f,keepArticlesCollapsed:y,showViewDetails:B,gridPadding:S,gridMargin:k,docTitleColor:P,docChildrenActiveColor:T,borderType:F,borderRadius:R,borderWidth:$,borderColor:M,buttonBorderRadius:O,buttonPadding:N,buttonMargin:D,buttonColor:z,buttonHoverColor:H,buttonTextColor:A,buttonText:L,buttonHoverTextColor:W}=e,I=[{label:"All",value:"all"},...Array.from({length:10},((e,t)=>({label:String(t+1),value:String(t+1)})))],j=[{label:(0,n.__)("weDocs Order","wedocs"),value:"menu_order"},{label:(0,n.__)("ID","wedocs"),value:"id"},{label:(0,n.__)("Name","wedocs"),value:"title"}],V=[{label:(0,n.__)("Ascending","wedocs"),value:"asc"},{label:(0,n.__)("Descending","wedocs"),value:"desc"}],U=[{label:"All",value:"all"},...Array.from({length:10},((e,t)=>({label:String(t+1),value:String(t+1)})))],{pages:G,sections:Y,articles:Z}=a((e=>{const{getEntityRecords:t}=e("core"),l=t("postType","docs",{status:"publish",per_page:-1,parent:0,orderby:w,order:C}),o=l?t("postType","docs",{status:"publish",parent_in:l.map((e=>e.id)),per_page:-1}):null,a=o?t("postType","docs",{status:"publish",parent_in:o.map((e=>e.id)),per_page:-1}):null;return{pages:l,sections:o,articles:a}}),[w,C]),J=(e=>{if("all"===_)return e;const t=parseInt(_),l=(r-1)*t,o=l+t;return e.slice(l,o)})((()=>{if(!G||!Y||!Z)return[];let e=[...G];return v&&v.length>0&&(e=e.filter((e=>!v.includes(e.id.toString())))),e=e.map((e=>{let t=Y.filter((t=>t.parent===e.id));"all"!==E&&(t=t.slice(0,parseInt(E))),t=t.map((e=>{let t=Z.filter((t=>t.parent===e.id));return"all"!==x&&(t=t.slice(0,parseInt(x))),{...e,articles:t}}));const l=t.reduce(((e,t)=>e+t.articles.length),0);return{...e,sections:t,articleCount:l}})),e})()),q=G?G.reduce(((e,t)=>(e[t.id]=t.title.rendered,e)),{}):{},K=(G&&G.map((e=>({value:e.id.toString(),label:e.title.rendered}))),e=>l=>{t({[e]:l})}),Q=v?v.map((e=>q[e]||e)):[];return(0,o.createElement)(s.Fragment,null,(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Doc Grid Settings","wedocs"),icon:d,initialOpen:!1},(0,o.createElement)(m.SelectControl,{value:b,options:[{label:"1x1",value:"1x1"},{label:"1x2",value:"1x2"}],label:(0,n.__)("DOCS GRID COLUMN STYLE","wedocs"),onChange:K("docStyle")}),(0,o.createElement)(m.SelectControl,{value:_,options:I,label:(0,n.__)("Docs per page","wedocs"),onChange:K("docsPerPage")}),(0,o.createElement)(m.FormTokenField,{value:Q,suggestions:Object.values(q),label:(0,n.__)("Exclude Docs","wedocs"),onChange:e=>{const l=e.map((e=>{const t=Object.entries(q).find((([t,l])=>l===e));return t?t[0]:e}));t({excludeDocs:l})}}),(0,o.createElement)(m.SelectControl,{value:C,options:V,label:(0,n.__)("Order","wedocs"),onChange:K("order")}),(0,o.createElement)(m.SelectControl,{value:w,options:j,label:(0,n.__)("Order by","wedocs"),onChange:K("orderBy")}),(0,o.createElement)(m.SelectControl,{value:E,options:U,label:(0,n.__)("Sections per doc","wedocs"),onChange:K("sectionsPerDoc")}),(0,o.createElement)(m.SelectControl,{value:x,options:U,label:(0,n.__)("Articles per section","wedocs"),onChange:K("articlesPerSection")}),(0,o.createElement)(m.PanelRow,null,(0,o.createElement)(m.ToggleControl,{checked:f,label:(0,n.__)("Show Doc Article","wedocs"),onChange:K("showDocArticle")})),(0,o.createElement)(m.PanelRow,null,(0,o.createElement)(m.ToggleControl,{checked:y,label:(0,n.__)("Keep Article Collapsed","wedocs"),onChange:K("keepArticlesCollapsed")})),(0,o.createElement)(m.PanelRow,null,(0,o.createElement)(m.ToggleControl,{checked:B,label:(0,n.__)("Show View Details Button","wedocs"),onChange:K("showViewDetails")})))),(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(h,{attributes:e,setAttributes:t})),(0,o.createElement)("div",{...l},g?(0,o.createElement)("div",{className:"backdrop"}):(0,o.createElement)("div",{className:"wedocs-block-wrapper"},(0,o.createElement)("div",{className:`wedocs-docs-grid wedocs-docs-grid--${b}`},c?(0,o.createElement)(Spinner,null):J.map((e=>((e,t)=>(0,o.createElement)("div",{key:e.id,className:"wedocs-docs-grid__item",style:t.item},(0,o.createElement)("h3",{className:"wedocs-docs-grid__title",style:t.title},e.title.rendered),((e,t)=>e.sections?(0,o.createElement)("div",{className:"wedocs-docs-grid__sections "+(y?"is-collapsed":"")},e.sections.map((e=>(0,o.createElement)("div",{key:e.id,className:"wedocs-docs-grid__section"},(0,o.createElement)("h4",{className:"wedocs-docs-grid__section-title",style:{...t.title,display:"flex",justifyContent:"space-between",alignItems:"center"}},(0,o.createElement)("span",null,e.title.rendered),f&&e.articles&&e.articles.length>0&&(0,o.createElement)("svg",{fill:"none",viewBox:"0 0 24 24",width:"16",strokeWidth:"2",stroke:"#acb8c4",className:y?"":"active"},(0,o.createElement)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"}))),f&&!y&&e.articles&&(0,o.createElement)("ul",{className:"wedocs-docs-grid__articles"},e.articles.map((e=>(0,o.createElement)("li",{key:e.id,className:"wedocs-docs-grid__article",style:t.children},e.title.rendered))))))),0===e.sections.length&&(0,o.createElement)("span",{className:"inside"},(0,o.createElement)("svg",{fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},(0,o.createElement)("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"})),(0,n.__)("This document has no sections yet. Check back later or wait for the author to add content.","wedocs"))):null)(e,t),B&&(0,o.createElement)("div",{className:"wedocs-docs-grid__details"},(0,o.createElement)("span",{className:"wedocs-docs-grid__details-link",style:t.button},t.button.text))))(e,(()=>{const e=S?`${S.top} ${S.right} ${S.bottom} ${S.left}`:"",t=k?`${k.top} ${k.right} ${k.bottom} ${k.left}`:"",l=N?`${N.top} ${N.right} ${N.bottom} ${N.left}`:"",o=O||"8px",a=D?`${D.top} ${D.right} ${D.bottom} ${D.left}`:"";return{item:{padding:e,margin:t,borderStyle:F||"solid",borderWidth:$||"1px",borderColor:M||"rgba(0, 0, 0, 0.1)",borderRadius:R||"8px",backgroundColor:"#fff"},title:{color:P||"#1e1e1e"},children:{color:T||"#0073aa"},button:{padding:l,margin:a,backgroundColor:z||"#0073aa",color:A||"#ffffff",text:L||(0,n.__)("View Details","wedocs"),borderRadius:o||"8px","--hover-bg":H||"#005177","--hover-color":W||"#ffffff"}}})())))))))},save:()=>null});const v=({attributes:e,setAttributes:t})=>{const{padding:l,margin:a,backgroundColor:r,textColor:i,hoverBackgroundColor:c,hoverTextColor:d,borderRadius:p,borderWidth:g,borderColor:b,borderStyle:h,fontSize:_,fontWeight:v}=e,C=(l,o=null)=>a=>{t(o?{[l]:{...e[l],[o]:a}}:{[l]:a})};return(0,o.createElement)(s.Fragment,null,(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Style Settings","wedocs"),initialOpen:!1},(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Button Style","wedocs"),value:e.buttonStyle,options:[{label:(0,n.__)("Primary","wedocs"),value:"primary"},{label:(0,n.__)("Secondary","wedocs"),value:"secondary"},{label:(0,n.__)("Outline","wedocs"),value:"outline"},{label:(0,n.__)("Ghost","wedocs"),value:"ghost"}],onChange:C("buttonStyle")}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Button Size","wedocs"),value:e.buttonSize,options:[{label:(0,n.__)("Small","wedocs"),value:"small"},{label:(0,n.__)("Medium","wedocs"),value:"medium"},{label:(0,n.__)("Large","wedocs"),value:"large"}],onChange:C("buttonSize")}),(0,o.createElement)(u.PanelColorSettings,{title:(0,n.__)("Color Settings","wedocs"),initialOpen:!1,colorSettings:[{value:i,onChange:C("textColor"),label:(0,n.__)("Text Color","wedocs")},{value:r,onChange:C("backgroundColor"),label:(0,n.__)("Background Color","wedocs")}]}),(0,o.createElement)(u.PanelColorSettings,{title:(0,n.__)("Hover Color Settings","wedocs"),initialOpen:!1,colorSettings:[{value:d,onChange:C("hoverTextColor"),label:(0,n.__)("Hover Text Color","wedocs")},{value:c,onChange:C("hoverBackgroundColor"),label:(0,n.__)("Hover Background Color","wedocs")}]})),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Spacing","wedocs"),initialOpen:!1},m.__experimentalBoxControl?(0,o.createElement)(s.Fragment,null,(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Padding","wedocs"),values:l,onChange:C("padding"),units:[{value:"px",label:"px",default:0},{value:"em",label:"em",default:0},{value:"%",label:"%",default:0}]}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Margin","wedocs"),values:a,onChange:C("margin"),units:[{value:"px",label:"px",default:0},{value:"em",label:"em",default:0},{value:"%",label:"%",default:0}]})):(0,o.createElement)(s.Fragment,null,(0,o.createElement)("p",{style:{marginBottom:"16px",color:"#666"}},(0,n.__)("Individual spacing controls (Padding & Margin)","wedocs")),(0,o.createElement)("div",{style:{marginBottom:"16px"}},(0,o.createElement)("strong",null,(0,n.__)("Padding","wedocs"))),(0,o.createElement)("div",{style:{marginBottom:"16px"}},(0,o.createElement)("strong",null,(0,n.__)("Margin","wedocs"))))),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Border & Typography","wedocs"),initialOpen:!1},m.__experimentalUnitControl?(0,o.createElement)(s.Fragment,null,(0,o.createElement)(m.__experimentalUnitControl,{label:(0,n.__)("Border Radius","wedocs"),value:p,onChange:C("borderRadius"),units:[{value:"px",label:"px",default:0},{value:"em",label:"em",default:0},{value:"%",label:"%",default:0}]}),(0,o.createElement)(m.__experimentalUnitControl,{label:(0,n.__)("Border Width","wedocs"),value:g,onChange:C("borderWidth"),units:[{value:"px",label:"px",default:0}]}),(0,o.createElement)(m.__experimentalUnitControl,{label:(0,n.__)("Font Size","wedocs"),value:_,onChange:C("fontSize"),units:[{value:"px",label:"px",default:16},{value:"em",label:"em",default:1},{value:"rem",label:"rem",default:1}]})):(0,o.createElement)(s.Fragment,null,(0,o.createElement)(m.RangeControl,{label:(0,n.__)("Border Radius (px)","wedocs"),value:parseInt(p),onChange:e=>C("borderRadius")(`${e}px`),min:0,max:50}),(0,o.createElement)(m.RangeControl,{label:(0,n.__)("Border Width (px)","wedocs"),value:parseInt(g),onChange:e=>C("borderWidth")(`${e}px`),min:0,max:10}),(0,o.createElement)(m.RangeControl,{label:(0,n.__)("Font Size (px)","wedocs"),value:parseInt(_),onChange:e=>C("fontSize")(`${e}px`),min:10,max:32})),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Border Style","wedocs"),value:h,options:[{label:(0,n.__)("Solid","wedocs"),value:"solid"},{label:(0,n.__)("Dashed","wedocs"),value:"dashed"},{label:(0,n.__)("Dotted","wedocs"),value:"dotted"},{label:(0,n.__)("None","wedocs"),value:"none"}],onChange:C("borderStyle")}),(0,o.createElement)(u.PanelColorSettings,{title:(0,n.__)("Border Color","wedocs"),initialOpen:!1,colorSettings:[{value:b,onChange:C("borderColor"),label:(0,n.__)("Border Color","wedocs")}]}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Font Weight","wedocs"),value:v,options:[{label:(0,n.__)("Normal","wedocs"),value:"normal"},{label:(0,n.__)("Bold","wedocs"),value:"bold"},{label:(0,n.__)("Light","wedocs"),value:"300"},{label:(0,n.__)("Medium","wedocs"),value:"500"},{label:(0,n.__)("Semi Bold","wedocs"),value:"600"},{label:(0,n.__)("Extra Bold","wedocs"),value:"800"}],onChange:C("fontWeight")}))))},C=JSON.parse('{"UU":"wedocs/print-button"}');(0,a.registerBlockType)(C.UU,{edit:({attributes:e,setAttributes:t})=>{const l=(0,u.useBlockProps)(),{layout:a,alignment:r,buttonText:i,showIcon:c,padding:d,margin:p,backgroundColor:g,textColor:b,hoverBackgroundColor:h,hoverTextColor:_,borderRadius:C,borderWidth:w,borderColor:E,borderStyle:x,fontSize:f,fontWeight:y,additionalClasses:B}=e,S={display:"inline-flex",alignItems:"center",justifyContent:"center",gap:c?"8px":"0",padding:`${d.top} ${d.right} ${d.bottom} ${d.left}`,margin:`${p.top} ${p.right} ${p.bottom} ${p.left}`,backgroundColor:g,color:b,border:`${w} ${x} ${E}`,borderRadius:C,fontSize:f,fontWeight:y,textDecoration:"none",cursor:"pointer",transition:"all 0.2s ease-in-out","--hover-bg-color":h,"--hover-text-color":_},k={textAlign:r,width:"100%"};return(0,o.createElement)(s.Fragment,null,(0,o.createElement)(u.BlockControls,null,(0,o.createElement)(u.AlignmentToolbar,{value:r,onChange:e=>t({alignment:e||"left"})})),(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("General Settings","wedocs"),initialOpen:!0},(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Layout","wedocs"),value:a,options:[{label:(0,n.__)("Layout 1 - Horizontal","wedocs"),value:"layout1"},{label:(0,n.__)("Layout 2 - Button Style","wedocs"),value:"layout2"},{label:(0,n.__)("Layout 3 - Vertical","wedocs"),value:"layout3"}],onChange:e=>t({layout:e})}),(0,o.createElement)(m.TextControl,{label:(0,n.__)("Button Text","wedocs"),value:i,onChange:e=>t({buttonText:e}),placeholder:(0,n.__)("Print","wedocs")}),(0,o.createElement)(m.PanelRow,null,(0,o.createElement)(m.ToggleControl,{label:(0,n.__)("Show Print Icon","wedocs"),checked:c,onChange:e=>t({showIcon:e})}))),(0,o.createElement)(v,{attributes:e,setAttributes:t}),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Advanced","wedocs"),initialOpen:!1},(0,o.createElement)(m.TextControl,{label:(0,n.__)("Additional CSS Classes","wedocs"),value:B,onChange:e=>t({additionalClasses:e}),help:(0,n.__)("Add custom CSS classes separated by spaces","wedocs")}))),(0,o.createElement)("div",{...l},(0,o.createElement)("div",{className:"wedocs-print-button-wrapper"},(()=>{switch(a){case"layout2":return(0,o.createElement)("div",{style:k},(0,o.createElement)("button",{className:`wedocs-print-button layout-2 ${B}`,style:S,onClick:e=>e.preventDefault()},c&&(0,o.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},(0,o.createElement)("path",{d:"M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"})),(0,o.createElement)("span",null,i||(0,n.__)("Print","wedocs"))));case"layout3":return(0,o.createElement)("div",{style:k},(0,o.createElement)("button",{className:`wedocs-print-button layout-3 ${B}`,style:{...S,flexDirection:"column",gap:"4px"},onClick:e=>e.preventDefault()},c&&(0,o.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},(0,o.createElement)("path",{d:"M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"})),(0,o.createElement)("span",{style:{fontSize:"12px"}},i||(0,n.__)("Print","wedocs"))));default:return(0,o.createElement)("div",{style:k},(0,o.createElement)("button",{className:`wedocs-print-button layout-1 ${B}`,style:S,onClick:e=>e.preventDefault()},c&&(0,o.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},(0,o.createElement)("path",{d:"M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"})),(0,o.createElement)("span",null,i||(0,n.__)("Print","wedocs"))))}})())))}})},609:e=>{e.exports=window.React}},l={};function o(e){var a=l[e];if(void 0!==a)return a.exports;var n=l[e]={exports:{}};return t[e](n,n.exports,o),n.exports}o.m=t,e=[],o.O=(t,l,a,n)=>{if(!l){var r=1/0;for(s=0;s<e.length;s++){l=e[s][0],a=e[s][1],n=e[s][2];for(var i=!0,c=0;c<l.length;c++)(!1&n||r>=n)&&Object.keys(o.O).every((e=>o.O[e](l[c])))?l.splice(c--,1):(i=!1,n<r&&(r=n));if(i){e.splice(s--,1);var d=a();void 0!==d&&(t=d)}}return t}n=n||0;for(var s=e.length;s>0&&e[s-1][2]>n;s--)e[s]=e[s-1];e[s]=[l,a,n]},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={366:0,337:0};o.O.j=t=>0===e[t];var t=(t,l)=>{var a,n,r=l[0],i=l[1],c=l[2],d=0;if(r.some((t=>0!==e[t]))){for(a in i)o.o(i,a)&&(o.m[a]=i[a]);if(c)var s=c(o)}for(t&&t(l);d<r.length;d++)n=r[d],o.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return o.O(s)},l=self.webpackChunkweDocs=self.webpackChunkweDocs||[];l.forEach(t.bind(null,0)),l.push=t.bind(null,l.push.bind(l))})();var a=o.O(void 0,[337],(()=>o(870)));a=o.O(a)})(); | |
| ...,(0,o.createElement)("div",{...l}, | |
| g?(0,o.createElement)("div",{className:"backdrop"}): | |
| (0,o.createElement)("div",{className:"wedocs-block-wrapper"}, | |
| (0,o.createElement)("div",{className:`wedocs-docs-grid wedocs-docs-grid--${b}`}, | |
| c ? (0,o.createElement)(m.Spinner,null) : J.map((e => ((e,t) => (0,o.createElement)("div",{key:e.id,className:"wedocs-docs-grid__item",style:t.item}, (0,o.createElement)("h3",{className:"wedocs-docs-grid__title",style:t.title}, e.title.rendered), /* ...rest unchanged... */ )))(e,t)) | |
| ) | |
| ) | |
| ) |
🧰 Tools
🪛 Biome (2.1.2)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
🤖 Prompt for AI Agents
In assets/build/block.js around line 1, the code references an unqualified
Spinner (runtime error); fix by importing Spinner in the source: add a Spinner
import to src/blocks/DocsGrid/edit.js (from @wordpress/components or
window.wp.components) and re-run the build so the compiled asset includes the
Spinner symbol, or as a temporary patch modify the built asset to replace the
unqualified Spinner usage with the components namespace (m.Spinner) and
rebuild/verify.
| <style> | ||
| #<?php echo esc_attr($block_id); ?> { | ||
| padding: <?php echo esc_attr($padding['top']); ?> <?php echo esc_attr($padding['right']); ?> <?php echo esc_attr($padding['bottom']); ?> <?php echo esc_attr($padding['left']); ?> !important; | ||
| margin: <?php echo esc_attr($margin['top']); ?> <?php echo esc_attr($margin['right']); ?> <?php echo esc_attr($margin['bottom']); ?> <?php echo esc_attr($margin['left']); ?> !important; | ||
| background-color: <?php echo esc_attr($background_color); ?> !important; | ||
| color: <?php echo esc_attr($text_color); ?> !important; | ||
| border: <?php echo esc_attr($border_width); ?> <?php echo esc_attr($border_style); ?> <?php echo esc_attr($border_color); ?> !important; | ||
| border-radius: <?php echo esc_attr($border_radius); ?> !important; | ||
| font-size: <?php echo esc_attr($font_size); ?> !important; | ||
| font-weight: <?php echo esc_attr($font_weight); ?> !important; | ||
| text-decoration: none !important; | ||
| cursor: pointer !important; | ||
| transition: all 0.2s ease-in-out !important; | ||
| display: inline-flex !important; | ||
| align-items: center !important; | ||
| justify-content: center !important; | ||
| gap: <?php echo $show_icon ? '8px' : '0'; ?> !important; | ||
| line-height: 1.4 !important; | ||
| } | ||
| <?php if ($layout === 'layout3'): ?> | ||
| #<?php echo esc_attr($block_id); ?> { | ||
| flex-direction: column !important; | ||
| gap: 4px !important; | ||
| } | ||
| <?php endif; ?> | ||
| #<?php echo esc_attr($block_id); ?>:hover { | ||
| background-color: <?php echo esc_attr($hover_bg_color); ?> !important; | ||
| color: <?php echo esc_attr($hover_text_color); ?> !important; | ||
| } | ||
| @media print { | ||
| #<?php echo esc_attr($block_id); ?>, | ||
| .wp-block-wedocs-print-button { | ||
| display: none !important; | ||
| } | ||
| } | ||
| </style> | ||
| <div class="wp-block-wedocs-print-button wedocs-print-button-wrapper" style="<?php echo esc_attr($container_styles); ?>"> | ||
| <?php echo $button_content; ?> | ||
| </div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scope print-hide CSS narrowly to avoid collateral hides.
The global [class*=print-button], [id*=wedocs-print] patterns in other CSS can hide unrelated content. Here you already hide the instance by id and wrapper; that’s sufficient.
@media print {
- #<?php echo esc_attr($block_id); ?>,
- .wp-block-wedocs-print-button {
- display: none !important;
- }
+ #<?php echo esc_attr($block_id); ?>,
+ .wp-block-wedocs-print-button { display: none !important; }
}Ensure the built stylesheet removes broad attribute selectors too (see comment in assets/build/style-block.css).
🤖 Prompt for AI Agents
In assets/build/blocks/PrintButton/render.php around lines 127 to 165, the print
CSS currently uses broad attribute/class selectors elsewhere which can hide
unrelated content; narrow the print-only rules to target only this block
instance by keeping the #<?php echo esc_attr($block_id); ?> selector and its
specific wrapper class (e.g. .wp-block-wedocs-print-button and the generated
wrapper) and remove any attribute or wildcard class selectors such as
[class*=print-button] or [id*=wedocs-print] from this file; also update the
build pipeline so assets/build/style-block.css does not include the broad
attribute selectors, ensuring only the instance ID and explicit wrapper class
are hidden in @media print.
| @@ -1,2 +1,3 @@ | |||
| .wp-block-wedocs-wedocs-search{--field-color: #FFFFFF;--field-bg-color: #FFFFFF;--field-icon-color: #FFFFFF;--field-btn-bg-color: #3B82F6;--field-icon-hover-color: #FFFFFF;--field-btn-bg-hover-color: #2563EB}.wedocs-search-input,.wedocs-editor-search-input{width:50%;display:flex;overflow:hidden;position:relative}.wedocs-search-input .search-field,.wedocs-editor-search-input .search-field{margin:0;width:100%;height:48px;font-size:14px;background:#fff;padding:14px 22px;border-radius:100px;border:1px solid #dbdbdb}.wedocs-search-input .search-field::-moz-placeholder, .wedocs-editor-search-input .search-field::-moz-placeholder{color:#c5c5c5}.wedocs-search-input .search-field::placeholder,.wedocs-editor-search-input .search-field::placeholder{color:#c5c5c5}.wedocs-search-input .search-field:focus,.wedocs-editor-search-input .search-field:focus{outline:none;box-shadow:none;border:1px solid #dbdbdb}.wedocs-search-input .search-submit,.wedocs-editor-search-input .search-submit{top:0;right:0;border:0;margin:0;height:100%;display:flex;cursor:pointer;width:-moz-fit-content;width:fit-content;padding:14px 26px;position:absolute;align-items:center;border-radius:100px}.wedocs-search-input{margin-left:auto;margin-bottom:4%}.wedocs-search-toggle{margin-bottom:0 !important}.wedocs-search-toggle .components-h-stack{flex-direction:row-reverse}.wedocs-search-color-settings .block-editor-panel-color-gradient-settings{border-top:0;padding-left:0;padding-right:0}.wedocs-search-color-settings .block-editor-panel-color-gradient-settings .block-editor-tools-panel-color-gradient-settings__item.first{margin-top:0}.radio-image-control-options{display:flex;flex-direction:row;justify-content:space-between}.radio-image-control-options .radio-image-option{margin-right:10px}.radio-image-control-options .radio-image-option label{cursor:pointer;display:block}.radio-image-control-options .radio-image-option input[type=radio]{display:none}.radio-image-control-options .radio-image-option label i,.radio-image-control-options .radio-image-option label img{width:30px;height:30px;display:block;background-size:cover;background-position:center}.backdrop{top:0;left:0;z-index:0;width:100%;opacity:.5;height:100%;background:#fff;position:absolute}.wp-block-wedocs-wedocs-search .wedocs-search-input .search-field{background-color:var(--field-color) !important}.wp-block-wedocs-wedocs-search .wedocs-search-input .search-field:hover{background-color:var(--field-bg-color) !important}.wp-block-wedocs-wedocs-search .wedocs-search-input .search-submit{background-color:var(--field-btn-bg-color) !important}.wp-block-wedocs-wedocs-search .wedocs-search-input .search-submit svg path{fill:var(--field-icon-color) !important}.wp-block-wedocs-wedocs-search .wedocs-search-input .search-submit svg path:hover{fill:var(--field-icon-hover-color) !important}.wp-block-wedocs-wedocs-search .wedocs-search-input .search-submit:hover{background-color:var(--field-btn-bg-hover-color) !important}.wp-block-wedocs-wedocs-search:not(.wp-block){display:block} | |||
| .wedocs-color-control{margin:1em 0}.wedocs-color-control label{display:block;margin-bottom:.5em}.wedocs-docs-pagination{margin:30px 0;text-align:center}.wedocs-docs-pagination ul{display:inline-flex;list-style:none;padding:0;margin:0;gap:5px}.wedocs-docs-pagination li{margin:0}.wedocs-docs-pagination button{display:inline-block;padding:8px 12px;border:1px solid var(--wedocs-pagination-border-color, #ddd);border-radius:var(--wedocs-border-radius, 4px);text-decoration:none;color:var(--wedocs-pagination-text-color, #333);background:var(--wedocs-pagination-background-color, #fff);cursor:pointer;transition:all .2s}.wedocs-docs-pagination button:hover{background:var(--wedocs-pagination-hover-color, #f5f5f5);color:var(--wedocs-pagination-text-hover-color, #0073aa)}.wedocs-docs-pagination button.is-active{background:var(--wedocs-pagination-hover-color, #f5f5f5);border-color:var(--wedocs-pagination-hover-color, #ccc)}.wedocs-block-wrapper{width:100%;max-width:1200px;margin:0 auto;padding:.5rem}.wedocs-preview-title{margin-bottom:1rem;font-size:1.1rem;color:var(--wedocs-text-secondary-color, #757575)}.wedocs-docs-grid{display:grid;gap:1.5rem;width:100%;margin:0;padding:0;list-style:none}.wedocs-docs-grid--1x1{grid-template-columns:1fr}.wedocs-docs-grid--1x2{grid-template-columns:repeat(2, 1fr)}@media(max-width: 768px){.wedocs-docs-grid--1x2{grid-template-columns:1fr}}.wedocs-docs-grid .inside{display:flex;color:#063250;font-size:18px;min-height:240px;list-style:none}.wedocs-docs-grid .inside svg{width:64px;height:24px;margin:2px .5rem 0 0}.wedocs-docs-grid__item{position:relative;background-color:#fff;transition:transform .2s,box-shadow .2s;list-style:none;padding:var(--wedocs-grid-padding, 1.5rem);margin:var(--wedocs-grid-margin, 0);border-width:var(--wedocs-border-width, 1px);border-style:var(--wedocs-border-type, solid);border-color:var(--wedocs-border-color, rgba(0, 0, 0, 0.1));border-radius:var(--wedocs-border-radius, 8px)}.wedocs-docs-grid__title{font-size:1.5rem;font-weight:800;color:var(--wedocs-doc-title-color, #1e1e1e);margin:0 0 .75rem;line-height:1.4}.wedocs-docs-grid__article-count{font-size:.875rem;color:var(--wedocs-text-secondary-color, #757575);margin:0}.wedocs-docs-grid__container{min-height:240px}.wedocs-docs-grid__sections{margin-top:1rem;padding:0}.wedocs-docs-grid__sections.is-collapsed .wedocs-docs-grid__articles{display:none}.wedocs-docs-grid__section-title{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none;display:flex;justify-content:space-between;align-items:center}.wedocs-docs-grid__section-title a{pointer-events:auto;text-decoration:none}.wedocs-docs-grid__section-title a:hover{text-decoration:underline}.wedocs-docs-grid__section-title svg{transition:transform .3s ease;cursor:pointer;flex-shrink:0}.wedocs-docs-grid__section-title svg.active{transform:rotate(180deg)}.wedocs-docs-grid__articles{max-height:1000px;overflow:hidden;transition:max-height .3s ease-in-out}.wedocs-docs-grid__articles.collapsed{max-height:0}.wedocs-docs-grid__articles li{opacity:1;transition:opacity .2s ease-in-out}.wedocs-docs-grid__articles.collapsed li{opacity:0}.wedocs-docs-grid__section{margin-bottom:1rem}.wedocs-docs-grid__section-title{font-size:1rem;color:var(--wedocs-doc-title-color, #1e1e1e);margin:.5rem 0}.wedocs-docs-grid__articles{margin:.5rem 0 .5rem 1rem;padding:0}.wedocs-docs-grid__articles li{color:var(--wedocs-doc-children-active-color, #0073aa);font-size:.875rem;margin-bottom:.25rem;margin-left:1rem}.wedocs-docs-grid__articles li ::marker{content:"•";color:var(--wedocs-doc-children-active-color, #0073aa);margin-right:.5rem}.wedocs-docs-grid__details{margin-top:1rem;padding-top:1rem;border-top:1px solid rgba(0,0,0,.1)}.wedocs-docs-grid__details-link{display:inline-block;padding:var(--wedocs-button-padding, 8px 12px);margin:var(--wedocs-button-margin, 0);background-color:var(--wedocs-button-color, #0073aa);color:var(--wedocs-button-text-color, #fff);border-radius:var(--wedocs-border-radius, 4px);font-size:.875rem;cursor:pointer;transition:all .2s;text-decoration:none}.wedocs-docs-grid__details-link:hover{background-color:var(--wedocs-button-hover-color, #005177);color:var(--wedocs-button-hover-text-color, #fff)}.wp-block-wedocs-docs .wedocs-docs-grid__item{cursor:default}[dir=rtl] .wedocs-docs-grid__details-link::after{content:"←"}.wedocs-docs-pagination{margin:30px 0;text-align:center}.wedocs-docs-pagination .page-numbers{display:inline-flex;list-style:none;padding:0;margin:0;gap:5px}.wedocs-docs-pagination .page-numbers li{margin:0;display:inline-block}.wedocs-docs-pagination .page-numbers a,.wedocs-docs-pagination .page-numbers span{display:inline-block;padding:8px 12px;min-width:32px;margin:0 4px;border:1px solid var(--wedocs-pagination-border-color, #ddd);border-radius:var(--wedocs-border-radius, 4px);background-color:var(--wedocs-pagination-background-color, #fff);color:var(--wedocs-pagination-text-color, #333);text-decoration:none;font-family:inherit;font-size:14px;line-height:1.4;text-align:center;transition:all .2s ease;cursor:pointer}.wedocs-docs-pagination .page-numbers a:hover:not(.current),.wedocs-docs-pagination .page-numbers span:hover:not(.current){background-color:var(--wedocs-pagination-hover-color, #f5f5f5);color:var(--wedocs-pagination-text-hover-color, #0073aa);border-color:var(--wedocs-pagination-hover-color, #ccc)}.wedocs-docs-pagination .page-numbers .current{background-color:var(--wedocs-pagination-hover-color, #f5f5f5);border-color:var(--wedocs-pagination-hover-color, #ccc);color:var(--wedocs-pagination-text-hover-color, #0073aa);cursor:default}.wedocs-docs-pagination .page-numbers .dots{border:none;padding:8px;cursor:default}.wedocs-docs-pagination .page-numbers .dots:hover{background:none;color:inherit}.wedocs-docs-pagination__button{display:inline-block;padding:8px 12px;min-width:32px;margin:0 4px;border:1px solid var(--wedocs-pagination-border-color, #ddd);border-radius:var(--wedocs-border-radius, 4px);background-color:var(--wedocs-pagination-background-color, #fff);color:var(--wedocs-pagination-text-color, #333);text-decoration:none;font-family:inherit;font-size:14px;line-height:1.4;text-align:center;transition:all .2s ease;cursor:pointer}.wedocs-docs-pagination__button:hover:not(.is-active){background-color:var(--wedocs-pagination-hover-color, #f5f5f5) !important;color:var(--wedocs-pagination-text-hover-color, #0073aa) !important;border-color:var(--wedocs-pagination-hover-color, #ccc) !important}.wedocs-docs-pagination__button.is-active{background-color:var(--wedocs-pagination-hover-color, #f5f5f5);border-color:var(--wedocs-pagination-hover-color, #ccc);color:var(--wedocs-pagination-text-hover-color, #0073aa);cursor:default} | |||
| .wedocs-color-control{margin-bottom:16px}.wedocs-color-control .components-base-control__label{margin-bottom:8px;font-size:12px;font-weight:500;color:#1e1e1e}.wedocs-color-control .components-color-palette{margin:0}.wedocs-color-control .components-circular-option-picker__custom-clear-wrapper{margin-top:0 !important}.wp-block-wedocs-print-button{display:block !important}.wp-block-wedocs-print-button .wedocs-print-button-wrapper{width:100% !important}.wp-block-wedocs-print-button .wedocs-print-button{display:inline-flex !important;align-items:center !important;justify-content:center !important;gap:8px !important;font-family:inherit !important;line-height:1.4 !important;text-align:center !important;text-decoration:none !important;outline:none !important;-webkit-user-select:none !important;-moz-user-select:none !important;user-select:none !important;white-space:nowrap !important;box-sizing:border-box !important}.wp-block-wedocs-print-button .wedocs-print-button:link,.wp-block-wedocs-print-button .wedocs-print-button:visited,.wp-block-wedocs-print-button .wedocs-print-button:hover,.wp-block-wedocs-print-button .wedocs-print-button:active,.wp-block-wedocs-print-button .wedocs-print-button:focus{color:inherit !important;text-decoration:none !important}.wp-block-wedocs-print-button .wedocs-print-button:hover,.wp-block-wedocs-print-button .wedocs-print-button:focus{text-decoration:none;transform:translateY(-1px);box-shadow:0 2px 4px rgba(0,0,0,.1);background-color:var(--hover-bg-color) !important;color:var(--hover-text-color) !important}.wp-block-wedocs-print-button .wedocs-print-button:active{transform:translateY(0)}.wp-block-wedocs-print-button .wedocs-print-button i{font-size:1em;line-height:1}.wp-block-wedocs-print-button .wedocs-print-button.layout-1{flex-direction:row;gap:8px}.wp-block-wedocs-print-button .wedocs-print-button.layout-2{flex-direction:row;gap:8px;border-radius:6px;box-shadow:0 1px 3px rgba(0,0,0,.1)}.wp-block-wedocs-print-button .wedocs-print-button.layout-3{flex-direction:column;gap:4px}.wp-block-wedocs-print-button .wedocs-print-button.layout-3 span{line-height:1.2}.wp-block-wedocs-print-button[style*="text-align: left"]{text-align:left}.wp-block-wedocs-print-button[style*="text-align: center"]{text-align:center}.wp-block-wedocs-print-button[style*="text-align: right"]{text-align:right}.block-editor-block-list__layout .wp-block-wedocs-print-button .wedocs-print-button{pointer-events:none}@media print{.wp-block-wedocs-print-button{display:none}}@media(max-width: 768px){.wp-block-wedocs-print-button .wedocs-print-button.layout-1,.wp-block-wedocs-print-button .wedocs-print-button.layout-2{flex-direction:column;gap:4px}.wp-block-wedocs-print-button .wedocs-print-button.large-size{font-size:16px}}@media(prefers-contrast: high){.wp-block-wedocs-print-button .wedocs-print-button{border-width:2px}.wp-block-wedocs-print-button .wedocs-print-button.ghost{border:2px solid currentColor}}@media(prefers-reduced-motion: reduce){.wp-block-wedocs-print-button .wedocs-print-button{transition:none}.wp-block-wedocs-print-button .wedocs-print-button:hover{transform:none}}@media print{.wp-block-wedocs-print-button,.wp-block-wedocs-print-button *,.wedocs-print-button-wrapper,.wedocs-print-button-wrapper *,.wedocs-print-button,.wedocs-print-button *,.wedocs-print-article,.wedocs-print-article *,a.wedocs-print-article,a.wedocs-print-article *,.wp-block-wedocs-print-button .layout-1,.wp-block-wedocs-print-button .layout-2,.wp-block-wedocs-print-button .layout-3,.wp-block-wedocs-print-button a,.wp-block-wedocs-print-button button,[class*=wedocs-print],[class*=wedocs-print] *,[class*=print-button],[class*=print-button] *,[id*=wedocs-print],[id*=wedocs-print] *,[id^=wedocs-print-btn-],[id^=wedocs-print-btn-] *{display:none !important;visibility:hidden !important;opacity:0 !important;height:0 !important;width:0 !important;margin:0 !important;padding:0 !important;overflow:hidden !important;position:absolute !important;left:-9999px !important;top:-9999px !important}div.wp-block-wedocs-print-button.wedocs-print-button-wrapper{display:none !important}*[title*=Print],*[title*=print],*[aria-label*=Print],*[aria-label*=print]{display:none !important}} | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Over-broad print hide selectors—risk of hiding unrelated content.
The final @media print rule hides any element whose class/id contains “print”, which is dangerous. Scope to the block wrapper and its button only.
Apply in SCSS (then rebuild), conceptually:
- @media print {
- .wp-block-wedocs-print-button,
- .wp-block-wedocs-print-button * ,
- .wedocs-print-button-wrapper,
- .wedocs-print-button-wrapper * ,
- .wedocs-print-button,
- .wedocs-print-button * ,
- .wedocs-print-article,
- .wedocs-print-article *,
- [class*=wedocs-print], [class*=wedocs-print] *, [class*=print-button], [class*=print-button] *, [id*=wedocs-print], [id*=wedocs-print] *, [id^=wedocs-print-btn-], [id^=wedocs-print-btn-] * { display:none !important; ... }
- *[title*=Print], *[title*=print], *[aria-label*=Print], *[aria-label*=print] { display:none !important; }
- }
+ @media print {
+ .wp-block-wedocs-print-button,
+ .wp-block-wedocs-print-button .wedocs-print-button,
+ a.wedocs-print-article { display: none !important; }
+ }Rebuild and verify no broad attribute selectors remain:
#!/bin/bash
rg -n '\[class\*\=| \[id\*\=|\[aria-label\*\=|\[title\*\=' assets/build/style-block.cssThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
assets/build/block.js (2)
1-1: Remove stray console.log in editor.
console.log("editor panel:", r)leaks to users. Drop before release.- console.log("editor panel:",r);
1-1: Fix typo in placeholder text.“Search for a top or question” → “Search for a topic or question”.
Apply in source, then rebuild:
- placeholder:(0,n.__)("Search for a top or question","wedocs") + placeholder:(0,n.__)("Search for a topic or question","wedocs")assets/build/blocks/PrintButton/render.php (2)
80-89: Add accessibility attributes to the interactive anchor.Provide
role="button"andaria-labelfor better a11y; current markup only setstitle.- '<a href="#" id="%s" class="%s layout-2" title="%s"> + '<a href="#" id="%s" class="%s layout-2" title="%s" role="button" aria-label="%s"> ... - '<a href="#" id="%s" class="%s layout-3" title="%s"> + '<a href="#" id="%s" class="%s layout-3" title="%s" role="button" aria-label="%s"> ... - '<a href="#" id="%s" class="%s layout-1" title="%s"> + '<a href="#" id="%s" class="%s layout-1" title="%s" role="button" aria-label="%s">Pass the same translated string you use for
titleas thearia-label.Also applies to: 94-103, 108-117
69-72: Sanitize custom class list more strictly.
additional_classesis freeform; escaping helps, but sanitizing each token is safer.Example:
$extra = array_filter( array_map( 'sanitize_html_class', preg_split( '/\s+/', (string) $additional_classes ) ) ); $css_classes = trim( 'wedocs-print-article wedocs-print-button ' . esc_attr( $layout ) . ' ' . implode( ' ', $extra ) );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
assets/build/block.js(1 hunks)assets/build/blocks/PrintButton/block.json(1 hunks)assets/build/blocks/PrintButton/render.php(1 hunks)src/blocks/PrintButton/Inspector.js(1 hunks)src/blocks/PrintButton/block.json(1 hunks)src/blocks/PrintButton/render.php(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- src/blocks/PrintButton/block.json
- src/blocks/PrintButton/render.php
- src/blocks/PrintButton/Inspector.js
🧰 Additional context used
🧬 Code graph analysis (2)
assets/build/blocks/PrintButton/render.php (2)
src/blocks/PrintButton/Inspector.js (1)
attributes(16-29)src/blocks/PrintButton/edit.js (1)
attributes(16-34)
assets/build/block.js (1)
src/blocks/DocsGrid/edit.js (1)
wp(16-16)
🪛 Biome (2.1.2)
assets/build/block.js
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
[error] 1-1: This variable is used before its declaration.
The variable is declared here:
(lint/correctness/noInvalidUseBeforeDeclaration)
🔇 Additional comments (7)
assets/build/blocks/PrintButton/block.json (2)
27-27: Ensure render.php returns a callable when using"render": "file:./render.php".WordPress expects the included file to return a callable. Verify that
render.phpreturns a callback (closure or function name) or that PHP registration suppliesrender_callbackseparately.If relying on block.json, adjust render.php to return the callable (see suggested diff in render.php comment).
1-107: Attributes and supports look consistent.Defaults and align support are sensible for this block.
Please confirm the custom “wedocs” category is registered via
block_categories_all(or equivalent) so the block appears properly in Inserter.assets/build/blocks/PrintButton/render.php (3)
152-157: Print CSS scope is reasonable.Hiding the instance ID and the wrapper class is sufficient and avoids broad selectors. Good.
Ensure any legacy global print-hide selectors in theme/plugin CSS (e.g., attribute contains selectors) were removed to prevent collateral hides.
41-49: Good: preserves “0” values when merging spacing.Filtering null/empty-string avoids dropping zero values.
121-165: No change required — block is registered via PHP render_callback.wedocs.php includes assets/build/blocks/PrintButton/render.php and calls register_block_type(..., ['render_callback' => 'render_wedocs_print_button']), so returning a callable from render.php is not required.
assets/build/block.js (2)
1-1: Fix ReferenceError: guardweDocsBlockVarsin Search block save().Optional chaining on an undeclared global throws. Guard access via
typeofor usewindow.weDocs_Vars.Apply in source (not the built file), then rebuild. Example fix:
- action: weDocsBlockVars?.siteUrl, + action: ( typeof window !== 'undefined' + && window.weDocs_Vars + && window.weDocs_Vars.siteUrl ) + ? window.weDocs_Vars.siteUrl + : '/',Run to confirm no remaining risky references:
#!/bin/bash set -euo pipefail rg -nP -C2 --hidden --no-ignore '\bweDocs(Block)?Vars\b'
1-1: Import/qualify Spinner to avoid runtime error.
Spinneris referenced unqualified; usewp.components.Spinneror import it.Preferred source fix (in the editor file):
+ import { Spinner } from '@wordpress/components'; ... - d ? (0,o.createElement)(Spinner,null) : J.map( ... ) + d ? (0,o.createElement)(Spinner,null) : J.map( ... )Quick alternative (built output, not recommended):
- d?(0,o.createElement)(Spinner,null):J.map( + d?(0,o.createElement)(m.Spinner,null):J.map(
Close issue
🆕 New Print Button Block Implementation
3 Commits Made:
feat: Add Print Button block- Core implementationfix: change color UI default block- UI improvementsfix: frontend design- Design refinements📁 Files Added/Modified:
New Block Files Created:
src/blocks/PrintButton/- Complete new block directory with:block.json- Block configuration and attributesedit.js- Block editor interface (195 lines)index.js- Block registrationInspector.js- Block settings panel (200+ lines)render.php- Server-side rendering (169 lines)style.scss- Block styling (253 lines)Core Files Modified:
wedocs.php- Added block registration and categorysrc/blocks/index.js- Registered new PrintButton blockassets/js/frontend.js- Enhanced print functionality🎨 Key Features Implemented:
1. Block Configuration (
block.json):wedocs/print-buttonwedocs(new custom category)2. Three Layout Variations:
3. Advanced Customization Options:
4. Print Functionality:
docspost type pages5. Block Category System:
🔧 Technical Implementation Details:
Server-Side Rendering (
render.php):docspages)Editor Interface (
edit.js):Styling (
style.scss):🎯 User Experience Improvements:
🔗 Integration Points:
Summary by CodeRabbit
New Features
Enhancements
Style