| 1 |
import { |
| 2 |
WRAPPER_MARGIN, |
| 3 |
WRAPPER_BACKGROUND, |
| 4 |
WRAPPER_PADDING, |
| 5 |
WRAPPER_BORDER, |
| 6 |
READING_TIME_SIZE, |
| 7 |
AI_ACTIONS_PADDING, |
| 8 |
AI_ACTIONS_BACKGROUND, |
| 9 |
AI_ACTIONS_BORDER, |
| 10 |
AI_ACTIONS_ICON_SIZE, |
| 11 |
LISTEN_PADDING, |
| 12 |
LISTEN_BACKGROUND, |
| 13 |
LISTEN_BORDER, |
| 14 |
LISTEN_ICON_SIZE |
| 15 |
} from "./constants"; |
| 16 |
import { generateBackgroundAttributes, generateDimensionsAttributes, generateResponsiveRangeAttributes, generateBorderShadowAttributes, generateTypographyAttributes } from "../../../util/helpers"; |
| 17 |
import * as typoPrefixs from "./typographyPrefixConstants"; |
| 18 |
import { settingFlag, settingText } from "./settingDefaults"; |
| 19 |
|
| 20 |
const attributes = { |
| 21 |
// the following 4 attributes is must required for responsive options and asset generation for frontend |
| 22 |
// responsive control attributes ⬇ |
| 23 |
resOption: { |
| 24 |
type: "string", |
| 25 |
default: "Desktop", |
| 26 |
}, |
| 27 |
// blockId attribute for making unique className and other uniqueness ⬇ |
| 28 |
blockId: { |
| 29 |
type: "string", |
| 30 |
}, |
| 31 |
blockRoot: { |
| 32 |
type: "string", |
| 33 |
default: "better_docs", |
| 34 |
}, |
| 35 |
// blockMeta is for keeping all the styles ⬇ |
| 36 |
blockMeta: { |
| 37 |
type: "object", |
| 38 |
}, |
| 39 |
|
| 40 |
// ── Reading Time ───────────────────────────────────────────────────────── |
| 41 |
// Defaults come from the Settings panel rather than from literals, so an |
| 42 |
// untouched control mirrors the site-wide value. See ./settingDefaults.js for |
| 43 |
// why that also makes an untouched instance keep tracking later changes. |
| 44 |
enableReadingTime: { |
| 45 |
type: "boolean", |
| 46 |
default: settingFlag("enable_estimated_reading_time"), |
| 47 |
}, |
| 48 |
readingTimeTitle:{ |
| 49 |
type:"string", |
| 50 |
default: settingText("estimated_reading_time_title"), |
| 51 |
}, |
| 52 |
readingTimeText:{ |
| 53 |
type:"string", |
| 54 |
default: settingText("estimated_reading_time_text", "min read"), |
| 55 |
}, |
| 56 |
singularReadingTimeText:{ |
| 57 |
type:"string", |
| 58 |
default: settingText("singular_estimated_reading_time_text", "min read"), |
| 59 |
}, |
| 60 |
readingTimeTextColor:{ |
| 61 |
type:"string", |
| 62 |
default:"#667085" |
| 63 |
}, |
| 64 |
|
| 65 |
// ── AI Actions ─────────────────────────────────────────────────────────── |
| 66 |
// Perplexity and Grok ship off by default; the rest ship on. The fallbacks |
| 67 |
// mirror Core\Settings::get_default() so the two halves cannot drift. |
| 68 |
enableAIActions: { |
| 69 |
type: "boolean", |
| 70 |
default: settingFlag("enable_ai_actions"), |
| 71 |
}, |
| 72 |
aiButtonLabel: { |
| 73 |
type: "string", |
| 74 |
default: settingText("ai_actions_button_label", "Copy page"), |
| 75 |
}, |
| 76 |
aiPromptTemplate: { |
| 77 |
type: "string", |
| 78 |
default: settingText( |
| 79 |
"ai_actions_prompt_template", |
| 80 |
"Read from {URL} so I can ask questions about it." |
| 81 |
), |
| 82 |
}, |
| 83 |
aiCopyPage: { |
| 84 |
type: "boolean", |
| 85 |
default: settingFlag("ai_actions_copy_page"), |
| 86 |
}, |
| 87 |
aiViewMarkdown: { |
| 88 |
type: "boolean", |
| 89 |
default: settingFlag("ai_actions_view_markdown"), |
| 90 |
}, |
| 91 |
aiChatGPT: { |
| 92 |
type: "boolean", |
| 93 |
default: settingFlag("ai_actions_chatgpt"), |
| 94 |
}, |
| 95 |
aiClaude: { |
| 96 |
type: "boolean", |
| 97 |
default: settingFlag("ai_actions_claude"), |
| 98 |
}, |
| 99 |
aiGemini: { |
| 100 |
type: "boolean", |
| 101 |
default: settingFlag("ai_actions_gemini"), |
| 102 |
}, |
| 103 |
aiPerplexity: { |
| 104 |
type: "boolean", |
| 105 |
default: settingFlag("ai_actions_perplexity", false), |
| 106 |
}, |
| 107 |
aiGrok: { |
| 108 |
type: "boolean", |
| 109 |
default: settingFlag("ai_actions_grok", false), |
| 110 |
}, |
| 111 |
aiActionsTextColor: { |
| 112 |
type: "string", |
| 113 |
default: "#667085", |
| 114 |
}, |
| 115 |
// Separate from the label colour: every icon in the button is stroked with |
| 116 |
// `currentColor`, so one value covers the copy glyph and the caret, and the |
| 117 |
// two can be tinted independently the way the Customizer allows. |
| 118 |
aiActionsIconColor: { |
| 119 |
type: "string", |
| 120 |
default: "#667085", |
| 121 |
}, |
| 122 |
|
| 123 |
// ── Listen ─────────────────────────────────────────────────────────────── |
| 124 |
// The player is the browser's own `speechSynthesis`, so there is nothing to |
| 125 |
// configure about the audio itself — only the label, whether the speed control |
| 126 |
// is offered, and how the pill looks. |
| 127 |
enableListen: { |
| 128 |
type: "boolean", |
| 129 |
default: settingFlag("enable_listen"), |
| 130 |
}, |
| 131 |
listenButtonLabel: { |
| 132 |
type: "string", |
| 133 |
default: settingText("listen_button_label", "Listen"), |
| 134 |
}, |
| 135 |
listenShowSpeed: { |
| 136 |
type: "boolean", |
| 137 |
default: settingFlag("listen_show_speed"), |
| 138 |
}, |
| 139 |
listenTextColor: { |
| 140 |
type: "string", |
| 141 |
default: "#667085", |
| 142 |
}, |
| 143 |
listenIconColor: { |
| 144 |
type: "string", |
| 145 |
default: "#667085", |
| 146 |
}, |
| 147 |
// The play button's fill, the progress bar's fill and the scrubber's ring, all |
| 148 |
// three of which read one custom property — see listen.scss. One control |
| 149 |
// because three would be three chances to end up with a play button that does |
| 150 |
// not match its own progress bar. |
| 151 |
listenAccentColor: { |
| 152 |
type: "string", |
| 153 |
default: "#1D2939", |
| 154 |
}, |
| 155 |
|
| 156 |
...generateBackgroundAttributes(WRAPPER_BACKGROUND, { |
| 157 |
defaultFillColor: "#F9FAFB", |
| 158 |
noOverlay: true, |
| 159 |
}), |
| 160 |
...generateDimensionsAttributes(WRAPPER_MARGIN, { |
| 161 |
top: 0, |
| 162 |
right: 0, |
| 163 |
bottom: 24, |
| 164 |
left: 0, |
| 165 |
isLinked: false, |
| 166 |
}), |
| 167 |
...generateDimensionsAttributes(WRAPPER_PADDING, { |
| 168 |
top: 5, |
| 169 |
right: 10, |
| 170 |
bottom: 5, |
| 171 |
left: 10, |
| 172 |
isLinked: false, |
| 173 |
}), |
| 174 |
...generateBorderShadowAttributes(WRAPPER_BORDER, { noShadow: true, noShdowHover:true }), |
| 175 |
...generateTypographyAttributes(Object.values(typoPrefixs)), |
| 176 |
...generateResponsiveRangeAttributes(READING_TIME_SIZE, { |
| 177 |
defaultRange: 14, |
| 178 |
}), |
| 179 |
|
| 180 |
// The AI Actions half starts from the same numbers as the Wrapper controls |
| 181 |
// above, because the two halves of the meta row are the same kind of pill and |
| 182 |
// a control that opens empty gives the author nothing to adjust *from*. |
| 183 |
// |
| 184 |
// The border itself stays unset — the button ships without one — but the |
| 185 |
// radius is stated, at the same 16px as the stylesheet and the reading-time |
| 186 |
// pill, so the control opens on the corner the button actually has. |
| 187 |
...generateBackgroundAttributes(AI_ACTIONS_BACKGROUND, { |
| 188 |
defaultFillColor: "#F9FAFB", |
| 189 |
noOverlay: true, |
| 190 |
}), |
| 191 |
...generateDimensionsAttributes(AI_ACTIONS_PADDING, { |
| 192 |
top: 5, |
| 193 |
right: 10, |
| 194 |
bottom: 5, |
| 195 |
left: 10, |
| 196 |
isLinked: false, |
| 197 |
}), |
| 198 |
...generateBorderShadowAttributes(AI_ACTIONS_BORDER, { |
| 199 |
rdsDefaults: { |
| 200 |
top: 16, |
| 201 |
right: 16, |
| 202 |
bottom: 16, |
| 203 |
left: 16, |
| 204 |
}, |
| 205 |
noShadow: true, |
| 206 |
noShdowHover: true, |
| 207 |
}), |
| 208 |
...generateResponsiveRangeAttributes(AI_ACTIONS_ICON_SIZE, { |
| 209 |
defaultRange: 14, |
| 210 |
}), |
| 211 |
|
| 212 |
// The Listen half starts from the same numbers again. All three controls in the |
| 213 |
// meta row are the same kind of pill, and a control that opens empty gives the |
| 214 |
// author nothing to adjust *from*. |
| 215 |
...generateBackgroundAttributes(LISTEN_BACKGROUND, { |
| 216 |
defaultFillColor: "#F9FAFB", |
| 217 |
noOverlay: true, |
| 218 |
}), |
| 219 |
...generateDimensionsAttributes(LISTEN_PADDING, { |
| 220 |
top: 5, |
| 221 |
right: 10, |
| 222 |
bottom: 5, |
| 223 |
left: 10, |
| 224 |
isLinked: false, |
| 225 |
}), |
| 226 |
...generateBorderShadowAttributes(LISTEN_BORDER, { |
| 227 |
rdsDefaults: { |
| 228 |
top: 16, |
| 229 |
right: 16, |
| 230 |
bottom: 16, |
| 231 |
left: 16, |
| 232 |
}, |
| 233 |
noShadow: true, |
| 234 |
noShdowHover: true, |
| 235 |
}), |
| 236 |
...generateResponsiveRangeAttributes(LISTEN_ICON_SIZE, { |
| 237 |
defaultRange: 14, |
| 238 |
}), |
| 239 |
}; |
| 240 |
|
| 241 |
export default attributes; |
| 242 |
|