| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
|
| 3 |
import { |
| 4 |
CODE_SNIPPET_WRAPPER_MARGIN, |
| 5 |
CODE_SNIPPET_WRAPPER_PADDING, |
| 6 |
CODE_SNIPPET_HEADER_PADDING, |
| 7 |
CODE_SNIPPET_LINE_NUMBERS_PADDING, |
| 8 |
CODE_SNIPPET_CODE_PADDING, |
| 9 |
} from './constants'; |
| 10 |
|
| 11 |
import { |
| 12 |
generateTypographyAttributes, |
| 13 |
generateDimensionsAttributes, |
| 14 |
} from '../../../util/helpers'; |
| 15 |
|
| 16 |
import * as prefixes from './typographyPrefixConstants'; |
| 17 |
|
| 18 |
const attributes = { |
| 19 |
// Required attributes for responsive options and asset generation |
| 20 |
resOption: { |
| 21 |
type: 'string', |
| 22 |
default: 'Desktop', |
| 23 |
}, |
| 24 |
blockId: { |
| 25 |
type: 'string', |
| 26 |
}, |
| 27 |
blockRoot: { |
| 28 |
type: 'string', |
| 29 |
default: 'better_docs', |
| 30 |
}, |
| 31 |
blockMeta: { |
| 32 |
type: 'object', |
| 33 |
}, |
| 34 |
|
| 35 |
// Content attributes |
| 36 |
codeContent: { |
| 37 |
type: "string", |
| 38 |
default: "", |
| 39 |
}, |
| 40 |
language: { |
| 41 |
type: "string", |
| 42 |
default: "javascript", |
| 43 |
}, |
| 44 |
// Additional languages for a multi-language snippet. Each item: |
| 45 |
// { language, codeContent, fileName }. Empty = single-language (default, |
| 46 |
// behaves exactly as before). When 1+ present, the header shows a |
| 47 |
// language dropdown to switch between the primary + these variants. |
| 48 |
codeVariants: { |
| 49 |
type: "array", |
| 50 |
default: [], |
| 51 |
}, |
| 52 |
showCopyButton: { |
| 53 |
type: "boolean", |
| 54 |
default: true, |
| 55 |
}, |
| 56 |
showHeader: { |
| 57 |
type: "boolean", |
| 58 |
default: true, |
| 59 |
}, |
| 60 |
showLineNumbers: { |
| 61 |
type: "boolean", |
| 62 |
default: false, |
| 63 |
}, |
| 64 |
theme: { |
| 65 |
type: "string", |
| 66 |
default: "light", |
| 67 |
}, |
| 68 |
|
| 69 |
// File Preview Header attributes |
| 70 |
fileName: { |
| 71 |
type: "string", |
| 72 |
default: "filename.js", |
| 73 |
}, |
| 74 |
showFileIcon: { |
| 75 |
type: "boolean", |
| 76 |
default: true, |
| 77 |
}, |
| 78 |
fileIcon: { |
| 79 |
type: "string", |
| 80 |
default: "", // URL to custom icon |
| 81 |
}, |
| 82 |
showTrafficLights: { |
| 83 |
type: "boolean", |
| 84 |
default: true, |
| 85 |
}, |
| 86 |
|
| 87 |
// Typography attributes |
| 88 |
...generateTypographyAttributes(Object.values(prefixes)), |
| 89 |
|
| 90 |
// Color attributes |
| 91 |
lineNumberColor: { |
| 92 |
type: "string", |
| 93 |
default: null, |
| 94 |
}, |
| 95 |
lineNumberBgColor: { |
| 96 |
type: "string", |
| 97 |
default: null, |
| 98 |
}, |
| 99 |
lineNumberBorderColor: { |
| 100 |
type: "string", |
| 101 |
default: null, |
| 102 |
}, |
| 103 |
lineNumberBorderWidth: { |
| 104 |
type: "number", |
| 105 |
default: 1, |
| 106 |
}, |
| 107 |
wrapperBackgroundColor: { |
| 108 |
type: "string", |
| 109 |
default: null, |
| 110 |
}, |
| 111 |
wrapperBorderColor: { |
| 112 |
type: "string", |
| 113 |
default: null, |
| 114 |
}, |
| 115 |
wrapperBorderWidth: { |
| 116 |
type: "number", |
| 117 |
default: 0, |
| 118 |
}, |
| 119 |
wrapperBorderRadius: { |
| 120 |
type: "number", |
| 121 |
default: 0, |
| 122 |
}, |
| 123 |
headerBackgroundColor: { |
| 124 |
type: "string", |
| 125 |
default: null, |
| 126 |
}, |
| 127 |
headerBorderColor: { |
| 128 |
type: "string", |
| 129 |
default: null, |
| 130 |
}, |
| 131 |
headerBorderWidth: { |
| 132 |
type: "number", |
| 133 |
default: 1, |
| 134 |
}, |
| 135 |
fileNameColor: { |
| 136 |
type: "string", |
| 137 |
default: null, |
| 138 |
}, |
| 139 |
copyButtonColor: { |
| 140 |
type: "string", |
| 141 |
default: null, |
| 142 |
}, |
| 143 |
copyButtonBorderColor: { |
| 144 |
type: "string", |
| 145 |
default: null, |
| 146 |
}, |
| 147 |
codeBackgroundColor: { |
| 148 |
type: "string", |
| 149 |
default: null, |
| 150 |
}, |
| 151 |
|
| 152 |
// Dimension attributes with null defaults for responsive consistency |
| 153 |
...generateDimensionsAttributes(CODE_SNIPPET_WRAPPER_MARGIN), |
| 154 |
...generateDimensionsAttributes(CODE_SNIPPET_WRAPPER_PADDING), |
| 155 |
...generateDimensionsAttributes(CODE_SNIPPET_HEADER_PADDING), |
| 156 |
...generateDimensionsAttributes(CODE_SNIPPET_LINE_NUMBERS_PADDING), |
| 157 |
...generateDimensionsAttributes(CODE_SNIPPET_CODE_PADDING), |
| 158 |
}; |
| 159 |
|
| 160 |
export default attributes; |
| 161 |
|