Skip to content

Commit e3459d4

Browse files
author
Daniel Cohen
committed
cldt-editor
1 parent da43d6c commit e3459d4

39 files changed

+4195
-19
lines changed

examples/.cldtrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cloud-name": "demo",
3+
"public-id": "sample.jpg",
4+
"prefix-disabled": "https://res.cloudinary.com/demo/image/upload/",
5+
"suffix-disabled": "/v0/sample.jpg"
6+
}

examples/README.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# CLDT Example Files
2+
3+
This directory contains example `.cldt` files to demonstrate various features of the CLDT Editor extension.
4+
5+
## Files Overview
6+
7+
### Basic Examples
8+
9+
- **simple-test.cldt** - Basic Cloudinary URL example
10+
- **simple-url.cldt** - Simple transformation URL
11+
- **url.cldt** - Standard URL format
12+
- **commented-url.cldt** - URL with comments
13+
14+
### Formatting Examples
15+
16+
- **formatted-with-spacing.cldt** - Example with proper spacing
17+
- **url-formatted.cldt** - Formatted URL structure
18+
- **url-with-indentation.cldt** - Indented URL format
19+
- **complex-url.cldt** - Complex transformation
20+
- **complex-url-formatted.cldt** - Complex transformation with formatting
21+
22+
### Feature Testing
23+
24+
- **variable-syntax-test.cldt** - Tests variable syntax highlighting
25+
- **test-highlighting.cldt** - Tests syntax highlighting
26+
- **test-hover-anchors.cldt** - Tests hover provider functionality
27+
- **if-else-test.cldt** - Tests conditional logic (if/else)
28+
- **multiline-text-test.cldt** - Tests multiline text handling
29+
30+
### Hints Feature Testing
31+
32+
#### 🎯 Float Dimension Test
33+
34+
**File:** `float-dimension-test.cldt`
35+
**Purpose:** Demonstrates float dimension detection in the hints system
36+
**Content:**
37+
38+
```
39+
https://res.cloudinary.com/demo/image/upload/w_500.5,h_300.75,c_fill/sample.jpg
40+
```
41+
42+
**Expected Hints:**
43+
44+
- ⚠️ Line 2: Width parameter 'w_500.5' contains a decimal point. Use an integer value instead (e.g., w_501).
45+
- ⚠️ Line 2: Height parameter 'h_300.75' contains a decimal point. Use an integer value instead (e.g., h_301).
46+
47+
#### 🎯 Invalid Variable Assignment Test
48+
49+
**File:** `invalid-variable-test.cldt`
50+
**Purpose:** Demonstrates invalid variable assignment detection from Cloudinary errors
51+
**Content:**
52+
53+
```
54+
$titlerand_!hellllo,
55+
```
56+
57+
**Expected Hints:**
58+
59+
- ❌ Line 3: Invalid assignment to variable '$titlerand' with value '!hellllo'. Check the variable syntax and value format.
60+
61+
#### 🎯 Scale Without Dimensions Test
62+
63+
**File:** `scale-no-dimensions-test.cldt`
64+
**Purpose:** Demonstrates info hint for scale without dimensions
65+
**Content:**
66+
67+
```
68+
https://res.cloudinary.com/demo/image/upload/c_scale,q_auto/sample.jpg
69+
```
70+
71+
**Expected Hints:**
72+
73+
- ℹ️ Using c*scale without width or height parameter. Consider adding w* or h\_ to specify dimensions.
74+
75+
#### 🎯 Correct Dimensions Test
76+
77+
**File:** `correct-dimensions-test.cldt`
78+
**Purpose:** Control test - no hints should appear
79+
**Content:**
80+
81+
```
82+
https://res.cloudinary.com/demo/image/upload/w_500,h_300,c_fill/sample.jpg
83+
```
84+
85+
**Expected Hints:** None (hints area should remain hidden)
86+
87+
## Testing the Hints Feature
88+
89+
1. Open any of the hints test files
90+
2. Run the command: "CLDT: Show Preview" (or use the keyboard shortcut)
91+
3. Observe the hints area below the header in the preview window
92+
4. The hints area will smoothly expand if any issues are detected
93+
5. Each hint shows:
94+
- An icon (⚠️ warning, ❌ error, ℹ️ info)
95+
- A clear description of the issue
96+
- Suggestions for how to fix it
97+
98+
## Hints Feature Benefits
99+
100+
- **Real-time feedback** on common Cloudinary URL issues
101+
- **Contextual help** with specific suggestions
102+
- **Learning tool** to understand Cloudinary best practices
103+
- **Error prevention** before deploying to production
104+
- **Visual indicators** for quick problem identification
105+
106+
## How to Use Examples
107+
108+
1. Open a `.cldt` file in VS Code
109+
2. The syntax highlighting will automatically activate
110+
3. Use hover to see parameter descriptions
111+
4. Run "CLDT: Show Preview" to see the image preview
112+
5. Use formatting commands to clean up the URL structure
113+
6. Check the hints area for any warnings or suggestions
114+
115+
## Adding Your Own Examples
116+
117+
Feel free to create your own `.cldt` files to test different Cloudinary transformations. The extension will automatically provide:
118+
119+
- Syntax highlighting
120+
- Hover information
121+
- Code completion
122+
- Formatting
123+
- Live preview with hints
124+
125+
## Need Help?
126+
127+
Refer to the main documentation files:
128+
129+
- `README.md` - Main documentation
130+
- `HINTS.md` - Detailed hints feature documentation
131+
- `FORMATTER.md` - Formatting feature documentation
132+
- `FEATURES-UPDATE.md` - Recent feature updates

examples/commented-url.cldt

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
https://res.cloudinary.com/elukas/image/upload/
2+
###
3+
# User-Definable Variables
4+
# All the values are relative to the fixed postcard dimension: 2560 x 3755 px
5+
###
6+
$city_!MEXICO%0ACITY!, # Name of the City/Destination
7+
$pos_!bottom!, # Position of the city text: top/bottom
8+
$belo_!demo:airbnb:BeloIcon!, # Belo Icon's Public ID, if empty don't show
9+
$belopos_!right!, # Bélo Icon position is opposite of $pos and left/right
10+
$foil_!true!, # If true, it will do the cut-out of the city text
11+
$co_!rgb:fefefe!, # Color of the text
12+
$lrpad_205, # Left & right padding of the text bounding box
13+
$tbpad_171, # Top or bottom padding of the text bounding box
14+
$radius_205, # Radius of the postcard
15+
$whbelo_171, # Width & Height of Bélo Icon
16+
$xybelo_120, # X & Y Coordinates/Padding of Bélo
17+
$cobelo_!ee3d0c!, # Color of the Bélo Icon
18+
$shdwco_!000000!, # Color of the shadow of the text
19+
$shdwstrength_1, # Strength/bluriness of the shadow of the text
20+
$shdwx_0, # X coordinate of the shadow in relevant to the text
21+
$shdwy_67, # Y coordinate of the shadow in relevant to the text
22+
$shdwo_20, # Shadow Opacity
23+
$finalw_600/ # Final Width
24+
25+
###
26+
# Captures important variables
27+
###
28+
$w_iw, # Initial Width
29+
$h_ih, # Initial Height
30+
$resizeratio_$finalw_div_$w, # Resize Ratio
31+
$wtext_$w_sub_$lrpad_sub_$lrpad, # Width of text bounding box after padding
32+
$htext_$h_div_3_sub_$tbpad/ # Height of text bounding box: a third of postcard height after padding
33+
34+
###
35+
# Calculates final values based on given final width
36+
###
37+
$flrpad_$resizeratio_mul_$lrpad, # Final Left & Right Padding
38+
$ftbpad_$resizeratio_mul_$tbpad, # Final Top or Bottom Padding
39+
$fradius_$resizeratio_mul_$radius,# Final Radius
40+
$fwhbelo_$resizeratio_mul_$whbelo,# Final Width & Height of Bélo Icon
41+
$fxybelo_$resizeratio_mul_$xybelo,# Final X & Y Coordinates/Padding of Bélo
42+
$fwtext_$resizeratio_mul_$wtext, # Final Width of text bounding box after padding
43+
$fhtext_$resizeratio_mul_$htext/ # Final Height of text bounding box
44+
45+
###
46+
# Calculates final shadow values
47+
###
48+
$fshdwx_$resizeratio_mul_$shdwx, # Final X coordinate of the shadow in relevant to the text
49+
$fshdwy_$resizeratio_mul_$shdwy, # Final Y coordinate of the shadow in relevant to the text
50+
$fshdwstrength_$shdwstrength_mul_2000_mul_$resizeratio/
51+
$fshdwstrength_$fshdwstrength_to_i/
52+
# Final Shadow Strength: 2000 is the max value Cloudinary can accept & convert it to Integer
53+
54+
###
55+
# Immediately reduce the canvas to final dimensions
56+
# This approach is for performance reason, always try working on smaller canvas/buffer
57+
###
58+
w_$finalw, # Resize to Final Width
59+
r_$fradius/ # Apply Radius
60+
61+
###
62+
# Create text buffer for the city
63+
# Builds the supporting variables to be re-used for shadow
64+
###
65+
l_text: # Text overlay starts
66+
Rubik_ # Font family
67+
999_ # Font size in pixels
68+
alignment_center_ # Text alignment for multi-lines
69+
weight_900_ # Font weight
70+
letter_spacing_-20_ # Letter spacing in pixels, relative to default spacing
71+
line_spacing_-150: # Line spacing/height in pixels, relative to default spacing
72+
$(city), # City Text
73+
co_$co, # Font color
74+
w_$fwtext,h_$fhtext,c_limit/# Set text as big as possible with given bounding box
75+
$txtl_current, # Save current image (city text) buffer as $txtl (Text Layer)
76+
$txtlh_h/ # Save current buffer's height to $txtlh (Text Layer Height)
77+
o_0, # Make it disappear, because it needs to be repositioned along with the shadow
78+
fl_layer_apply/ # Close the layer
79+
80+
###
81+
# Create shadow buffer from text buffer
82+
# Our overlay tends to cut off the shadows causing a weird hard line on the shadow
83+
###
84+
l_$txtl/ # Overlay from buffer
85+
e_replace_color:$shdwco/ # Change color
86+
e_blur:$fshdwstrength, # Using e_blur instead of e_shadow to support color and opacity
87+
c_lpad,w_$finalw,h_$fhtext/ # Resize to final dimension
88+
if_$city_ne_!%20!,e_trim:0/ # Trim it without removing/cut-off the shadow on weird location (and only trim if it's a non-empty string)
89+
$shdwl_current, # Save current shadow buffer as $shdwl (Shadow Layer)
90+
$shdwlh_h/ # Save current shadow's height to $shdwlh (Shadow Layer Height)
91+
o_0, # Make it disappear, because it needs to be repositioned along with the text
92+
fl_layer_apply/ # Close the layer
93+
94+
###
95+
# Calculate half-height difference between text buffer and shadow buffer
96+
###
97+
$deltah_$shdwlh_sub_$txtlh/$deltah_$deltah_div_2/
98+
99+
###
100+
# Calculates X & Y for Text & Bélo Layers
101+
# X,Y Coordinates need to be calculated since x/y behaves inwards for positive value and outwards for negative value
102+
# Break it to 2 IFs, since we don't support nested-IFs
103+
###
104+
# Y-Axis
105+
if_$pos_eq_!top!/ # If Top Position
106+
$ftxty_$ftbpad/
107+
$ffshdwy_$ftbpad_sub_$deltah_add_$fshdwy/
108+
$fbeloy_h_sub_$fwhbelo_sub_$fxybelo/
109+
if_else/ # Else Bottom Position
110+
$ftxty_h_sub_$txtlh_sub_$ftbpad/
111+
$ffshdwy_h_sub_$txtlh_sub_$ftbpad_sub_$deltah_add_$fshdwy/
112+
$fbeloy_$fxybelo/
113+
if_end/
114+
115+
# X-Axis
116+
if_$belopos_eq_!left!/ # If Bélo Left Position
117+
$fbelox_$fxybelo/
118+
if_else/ # Else Bélo Right Position
119+
$fbelox_w_sub_$fwhbelo_sub_$fxybelo/
120+
if_end/
121+
122+
###
123+
# Shadow Overlay
124+
# First so it can be underneath the city text
125+
# Separate layer for shadow and city text, so it can punch-out/cut-out city text layer but not shadow layer
126+
###
127+
l_$shdwl/o_$shdwo,g_north,y_$ffshdwy,x_$fshdwx,fl_layer_apply.no_overflow/
128+
129+
###
130+
# City Text Overlay
131+
# If Foil, punch it out! (make it transparent)
132+
# We don't support IF inside overlay, such as:
133+
# l_$txtl/if_$foil_eq_!true!/e_cut_out/if_end/g_north,y_$ftxty,fl_layer_apply/
134+
###
135+
if_$foil_eq_!true!/
136+
l_$txtl/g_north,y_$ftxty,fl_layer_apply,e_cut_out/
137+
if_else/
138+
l_$txtl/g_north,y_$ftxty,fl_layer_apply/
139+
if_end/
140+
141+
###
142+
# Bélo Overlay
143+
# Only show if it's not empty
144+
###
145+
if_$belo_ne_!!_and_$foil_ne_!true!/
146+
l_$belo,w_$fwhbelo,e_replace_color:$cobelo/x_$fbelox,y_$fbeloy,g_north_west,fl_layer_apply/
147+
if_end/
148+
if_$belo_ne_!!_and_$foil_eq_!true!/
149+
l_$belo,w_$fwhbelo,e_replace_color:$cobelo/x_$fbelox,y_$fbeloy,g_north_west,e_cut_out,fl_layer_apply/
150+
if_end/
151+
152+
###
153+
# Postcard Public ID
154+
###
155+
demo/airbnb/Mexico%20City.png
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
https://res.cloudinary.com/cld-daniel-dynamic-folders/image/upload/
2+
3+
if_isndef_$imgcovermrand/
4+
$imgcovermrand_!figma-exports:6410!/
5+
if_end/
6+
7+
if_isndef_$rectangle86/
8+
$rectangle86_!figma-exports:9a77287dc964f3be41be38f56980572465e6f4fe!/
9+
if_end/
10+
11+
if_isndef_$rectangle861/
12+
$rectangle861_!figma-exports:011965992ad9bfbd815db92ba2db91ac1265d14e!/
13+
if_end/
14+
15+
if_isndef_$rectangle87/
16+
$rectangle87_!figma-exports:e2ef0d998306941f4fe1551f9329abbf318096fe!/
17+
if_end/
18+
19+
if_isndef_$titlerand/
20+
$titlerand_!Create%20scene%20from%20inspirational%20imagery!/
21+
if_end/
22+
23+
if_isndef_$titlerand1/
24+
$titlerand1_!asdf!/
25+
if_end/
26+
27+
if_isndef_$avatar/
28+
$avatar_!figma-exports:6423!/
29+
if_end/
30+
31+
b_rgb:ffffff,g_north_west,o_0,w_556,h_408/
32+
l_$imgcovermrand,c_fit/
33+
x_0,y_0,w_557,h_304,g_north_west,fl_layer_apply/
34+
35+
l_$rectangle86,c_fit/
36+
x_-15,y_56,w_205,h_205,c_crop,g_north_west,fl_layer_apply/
37+
38+
l_$rectangle861,c_fit/
39+
x_172,y_13,w_205,h_205,c_fill,g_north_west,fl_layer_apply/
40+
41+
l_empty,b_rgb:00f189,c_fill/
42+
bo_3px_solid_rgb:ffffff/
43+
x_136,y_120,w_28,h_33,g_north_west,fl_layer_apply/
44+
45+
l_empty,b_rgb:ffffff,c_fill/
46+
x_0,y_275,w_108,h_52,g_north_west,fl_layer_apply/
47+
48+
l_$rectangle87,c_fit/
49+
x_273,y_32,w_286,h_273,c_fill,g_north_west,fl_layer_apply/
50+
51+
l_text:Raleway_24_bold_line_spacing_0_letter_spacing_0_left:$(titlerand),c_fit,w_509,co_rgb:212b36/
52+
x_24,y_337,g_north_west,fl_layer_apply/
53+
54+
l_text:Raleway_18_line_spacing_0_letter_spacing_0_left:$(titlerand1),c_fit,w_509,co_rgb:747775/
55+
x_24,y_362,g_north_west,fl_layer_apply/
56+
57+
l_empty,b_rgb:e84a94,c_fill/
58+
x_46,y_269,w_21,h_17,g_north_west,fl_layer_apply/
59+
60+
l_empty,b_rgb:d9d9d9,c_fill/
61+
x_46,y_269,w_21,h_17,g_north_west,fl_layer_apply/
62+
63+
l_empty,b_rgb:d9d9d9,c_fill/
64+
x_42,y_276,w_21,h_19,g_north_west,fl_layer_apply/
65+
66+
l_empty,b_rgb:e5e8eb,c_fill/
67+
x_45,y_270,w_21,h_17,g_north_west,fl_layer_apply/
68+
69+
l_empty,b_rgb:e84a94,c_fill/
70+
x_44,y_272,w_21,h_17,g_north_west,fl_layer_apply/
71+
72+
v0/
73+
sample
74+

examples/complex-url.cldt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
https://res.cloudinary.com/cld-daniel-dynamic-folders/image/upload/if_isndef_$imgcovermrand/$imgcovermrand_!figma-exports:6410!/if_end/if_isndef_$rectangle86/$rectangle86_!figma-exports:9a77287dc964f3be41be38f56980572465e6f4fe!/if_end/if_isndef_$rectangle861/$rectangle861_!figma-exports:011965992ad9bfbd815db92ba2db91ac1265d14e!/if_end/if_isndef_$rectangle87/$rectangle87_!figma-exports:e2ef0d998306941f4fe1551f9329abbf318096fe!/if_end/if_isndef_$titlerand/$titlerand_!Create%20scene%20from%20inspirational%20imagery!/if_end/if_isndef_$titlerand1/$titlerand1_!asdf!/if_end/if_isndef_$avatar/$avatar_!figma-exports:6423!/if_end/b_rgb:ffffff,g_north_west,o_0,w_556.5,h_408/l_$imgcovermrand,c_fit/x_0,y_0,w_557,h_304,g_north_west,fl_layer_apply/l_$rectangle86,c_fit/x_-15,y_56,w_205,h_205,c_crop,g_north_west,fl_layer_apply/l_$rectangle861,c_fit/x_172,y_13,w_205,h_205,c_fill,g_north_west,fl_layer_apply/l_empty,b_rgb:00f189,c_fill/bo_3px_solid_rgb:ffffff/x_136,y_120,w_28,h_33,g_north_west,fl_layer_apply/l_empty,b_rgb:ffffff,c_fill/x_0,y_275,w_108,h_52,g_north_west,fl_layer_apply/l_$rectangle87,c_fit/x_273,y_32,w_286,h_273,c_fill,g_north_west,fl_layer_apply/l_text:Raleway_24_bold_line_spacing_0_letter_spacing_0_left:$(titlerand),c_fit,w_509,co_rgb:212b36/x_24,y_337,g_north_west,fl_layer_apply/l_text:Raleway_18_line_spacing_0_letter_spacing_0_left:$(titlerand1),c_fit,w_509,co_rgb:747775/x_24,y_362,g_north_west,fl_layer_apply/l_empty,b_rgb:e84a94,c_fill/x_46,y_269,w_21,h_17,g_north_west,fl_layer_apply/l_empty,b_rgb:d9d9d9,c_fill/x_46,y_269,w_21,h_17,g_north_west,fl_layer_apply/l_empty,b_rgb:d9d9d9,c_fill/x_42,y_276,w_21,h_19,g_north_west,fl_layer_apply/l_empty,b_rgb:e5e8eb,c_fill/x_45,y_270,w_21,h_17,g_north_west,fl_layer_apply/l_empty,b_rgb:e84a94,c_fill/x_44,y_272,w_21,h_17,g_north_west,fl_layer_apply/v0/sample
2+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Test file with correct integer dimensions (no hints should appear)
2+
https://res.cloudinary.com/demo/image/upload/w_500,h_300,c_fill/sample.jpg
3+

examples/float-dimension-test.cldt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Test file for float dimensions (should trigger hints)
2+
https://res.cloudinary.com/demo/image/upload/w_500.5,h_300.75,c_fill/sample.jpg
3+

0 commit comments

Comments
 (0)