Skip to content

Commit fcaec90

Browse files
committed
feat: add advanced editor tools to Office App
- Added text alignment buttons (Left, Center, Right, Justify) with inline SVGs. - Added font family (Inter, JetBrains Mono, Georgia, Arial, Times New Roman), size (10px - 48px), and text color picker selectors. - Bound fontName, fontSize, and foreColor execCommands to the corresponding input controls.
1 parent 1271c20 commit fcaec90

2 files changed

Lines changed: 59 additions & 7 deletions

File tree

public/system-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@
190190
{
191191
"path": "/system/apps/office/app.js",
192192
"type": "file",
193-
"size": 15037,
194-
"mtime": 1779447299714.5737
193+
"size": 18486,
194+
"mtime": 1779447539534.429
195195
},
196196
{
197197
"path": "/system/apps/office/app.json",

public/system/apps/office/app.js

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,40 @@ export async function launch(ctx, options = {}) {
4747
<button class="toolbar-btn" data-cmd="underline"><u>U</u></button>
4848
</div>
4949
<div style="width: 1px; height: 24px; background: #333; margin: 0 8px;"></div>
50-
<select class="toolbar-select">
51-
<option>Inter</option>
52-
<option>JetBrains Mono</option>
53-
<option>Georgia</option>
54-
</select>
50+
<div style="display: flex; gap: 4px;">
51+
<button class="toolbar-btn" data-cmd="justifyLeft" title="Align Left">
52+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="17" y1="10" x2="3" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="17" y1="18" x2="3" y2="18"></line></svg>
53+
</button>
54+
<button class="toolbar-btn" data-cmd="justifyCenter" title="Align Center">
55+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="10" x2="6" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="18" y1="18" x2="6" y2="18"></line></svg>
56+
</button>
57+
<button class="toolbar-btn" data-cmd="justifyRight" title="Align Right">
58+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="10" x2="7" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="21" y1="18" x2="7" y2="18"></line></svg>
59+
</button>
60+
<button class="toolbar-btn" data-cmd="justifyFull" title="Justify">
61+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" y1="10" x2="3" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="21" y1="18" x2="3" y2="18"></line></svg>
62+
</button>
63+
</div>
64+
<div style="width: 1px; height: 24px; background: #333; margin: 0 8px;"></div>
65+
<div style="display: flex; align-items: center; gap: 8px;">
66+
<select class="toolbar-select" id="office-font" title="Font Family" style="width: 120px;">
67+
<option value="Inter">Inter</option>
68+
<option value="JetBrains Mono">JetBrains Mono</option>
69+
<option value="Georgia">Georgia</option>
70+
<option value="Arial">Arial</option>
71+
<option value="Times New Roman">Times New Roman</option>
72+
</select>
73+
<select class="toolbar-select" id="office-size" title="Font Size" style="width: 70px;">
74+
<option value="1">10px</option>
75+
<option value="2">13px</option>
76+
<option value="3" selected>16px</option>
77+
<option value="4">18px</option>
78+
<option value="5">24px</option>
79+
<option value="6">32px</option>
80+
<option value="7">48px</option>
81+
</select>
82+
<input type="color" id="office-color" style="width: 24px; height: 24px; border: 1px solid #333; padding: 0; background: transparent; cursor: pointer; border-radius: 4px;" title="Text Color" value="#eeeeee">
83+
</div>
5584
</div>
5685
5786
<div class="office-editor-viewport" style="flex: 1; overflow-y: auto; padding: 40px 0; background: #050505; perspective: 1000px;">
@@ -322,6 +351,29 @@ export async function launch(ctx, options = {}) {
322351
}
323352
};
324353

354+
// Wire up font family, size and color
355+
const fontSelect = content.querySelector('#office-font');
356+
const sizeSelect = content.querySelector('#office-size');
357+
const colorPicker = content.querySelector('#office-color');
358+
359+
if (fontSelect) {
360+
fontSelect.onchange = () => {
361+
document.execCommand('fontName', false, fontSelect.value);
362+
};
363+
}
364+
365+
if (sizeSelect) {
366+
sizeSelect.onchange = () => {
367+
document.execCommand('fontSize', false, sizeSelect.value);
368+
};
369+
}
370+
371+
if (colorPicker) {
372+
colorPicker.oninput = () => {
373+
document.execCommand('foreColor', false, colorPicker.value);
374+
};
375+
}
376+
325377
if (options.path) {
326378
loadFile(options.path);
327379
}

0 commit comments

Comments
 (0)