iwork-mcp 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -485,6 +485,9 @@ export function registerNumbersTools(server) {
485
485
  const doc = app.documents.byName(params.documentName);
486
486
  const sheet = params.sheetName ? doc.sheets.byName(params.sheetName) : doc.sheets[0];
487
487
  const table = params.tableName ? sheet.tables.byName(params.tableName) : sheet.tables[0];
488
+ // Merging fails if range spans header/non-header boundaries — clear headers first
489
+ if (table.headerRowCount() > 0) table.headerRowCount = 0;
490
+ if (table.headerColumnCount() > 0) table.headerColumnCount = 0;
488
491
  const range = table.ranges[params.cellRange];
489
492
  range.merge();
490
493
  return JSON.stringify({ merged: true, cellRange: params.cellRange });
@@ -605,9 +608,9 @@ export function registerNumbersTools(server) {
605
608
  }
606
609
 
607
610
  function hexToRGB(hex) {
608
- const r = parseInt(hex.slice(1, 3), 16) / 255;
609
- const g = parseInt(hex.slice(3, 5), 16) / 255;
610
- const b = parseInt(hex.slice(5, 7), 16) / 255;
611
+ const r = parseInt(hex.slice(1, 3), 16) * 257;
612
+ const g = parseInt(hex.slice(3, 5), 16) * 257;
613
+ const b = parseInt(hex.slice(5, 7), 16) * 257;
611
614
  return [r, g, b];
612
615
  }
613
616
 
@@ -615,12 +618,10 @@ export function registerNumbersTools(server) {
615
618
  if (fmt.fontSize !== undefined) cell.fontSize = fmt.fontSize;
616
619
  if (fmt.fontName !== undefined) cell.fontName = fmt.fontName;
617
620
  if (fmt.textColor !== undefined) {
618
- const [r, g, b] = hexToRGB(fmt.textColor);
619
- cell.textColor = [r, g, b];
621
+ cell.textColor = hexToRGB(fmt.textColor);
620
622
  }
621
623
  if (fmt.backgroundColor !== undefined) {
622
- const [r, g, b] = hexToRGB(fmt.backgroundColor);
623
- cell.backgroundColor = [r, g, b];
624
+ cell.backgroundColor = hexToRGB(fmt.backgroundColor);
624
625
  }
625
626
  if (fmt.alignment !== undefined) {
626
627
  cell.alignment = fmt.alignment;
@@ -631,16 +632,16 @@ export function registerNumbersTools(server) {
631
632
  if (fmt.textWrap !== undefined) {
632
633
  cell.textWrap = fmt.textWrap;
633
634
  }
634
- // Bold/italic: switch font to bold/italic variant
635
+ // Bold/italic: switch font to bold/italic variant (PostScript names)
635
636
  if (fmt.bold !== undefined || fmt.italic !== undefined) {
636
637
  let fontName = fmt.fontName || cell.fontName();
637
- const baseName = fontName.replace(/ ?(Bold|Italic|Bold Italic|BoldItalic)$/i, "").trim();
638
- let suffix = "";
638
+ const baseName = fontName.replace(/[- ]?(Bold ?Italic|BoldItalic|Bold|Italic)$/i, "").trim();
639
639
  const wantBold = fmt.bold !== undefined ? fmt.bold : /Bold/i.test(fontName);
640
640
  const wantItalic = fmt.italic !== undefined ? fmt.italic : /Italic/i.test(fontName);
641
- if (wantBold && wantItalic) suffix = " Bold Italic";
642
- else if (wantBold) suffix = " Bold";
643
- else if (wantItalic) suffix = " Italic";
641
+ let suffix = "";
642
+ if (wantBold && wantItalic) suffix = "-BoldItalic";
643
+ else if (wantBold) suffix = "-Bold";
644
+ else if (wantItalic) suffix = "-Italic";
644
645
  cell.fontName = baseName + suffix;
645
646
  }
646
647
  }
@@ -728,8 +729,9 @@ export function registerNumbersTools(server) {
728
729
  sheet.tables.push(table);
729
730
  table.name = params.tableName || params.sheetName;
730
731
 
731
- // Set header row count (default 0 = no grey header styling)
732
+ // Set header counts (default 0 = no header styling, allows merging across all cells)
732
733
  table.headerRowCount = (params.headerRowCount !== null && params.headerRowCount !== undefined) ? params.headerRowCount : 0;
734
+ table.headerColumnCount = 0;
733
735
 
734
736
  // Write all data
735
737
  const colCount = table.columnCount();
@@ -758,7 +760,7 @@ export function registerNumbersTools(server) {
758
760
 
759
761
  // Apply formatting
760
762
  function hexToRGB(hex) {
761
- return [parseInt(hex.slice(1,3),16)/255, parseInt(hex.slice(3,5),16)/255, parseInt(hex.slice(5,7),16)/255];
763
+ return [parseInt(hex.slice(1,3),16)*257, parseInt(hex.slice(3,5),16)*257, parseInt(hex.slice(5,7),16)*257];
762
764
  }
763
765
 
764
766
  if (params.formatting) {
@@ -779,13 +781,13 @@ export function registerNumbersTools(server) {
779
781
  if (fmt.textWrap !== undefined) cell.textWrap = fmt.textWrap;
780
782
  if (fmt.bold !== undefined || fmt.italic !== undefined) {
781
783
  let fontName = fmt.fontName || cell.fontName();
782
- const baseName = fontName.replace(/ ?(Bold|Italic|Bold Italic|BoldItalic)$/i, "").trim();
783
- let suffix = "";
784
+ const baseName = fontName.replace(/[- ]?(Bold ?Italic|BoldItalic|Bold|Italic)$/i, "").trim();
784
785
  const wantBold = fmt.bold !== undefined ? fmt.bold : /Bold/i.test(fontName);
785
786
  const wantItalic = fmt.italic !== undefined ? fmt.italic : /Italic/i.test(fontName);
786
- if (wantBold && wantItalic) suffix = " Bold Italic";
787
- else if (wantBold) suffix = " Bold";
788
- else if (wantItalic) suffix = " Italic";
787
+ let suffix = "";
788
+ if (wantBold && wantItalic) suffix = "-BoldItalic";
789
+ else if (wantBold) suffix = "-Bold";
790
+ else if (wantItalic) suffix = "-Italic";
789
791
  cell.fontName = baseName + suffix;
790
792
  }
791
793
  }
@@ -194,9 +194,9 @@ export function registerPagesTools(server) {
194
194
  if (fmt.italic !== undefined) paragraph.italic = fmt.italic;
195
195
  if (fmt.textColor !== undefined) {
196
196
  const hex = fmt.textColor;
197
- const r = parseInt(hex.slice(1, 3), 16) / 255;
198
- const g = parseInt(hex.slice(3, 5), 16) / 255;
199
- const b = parseInt(hex.slice(5, 7), 16) / 255;
197
+ const r = parseInt(hex.slice(1, 3), 16) * 257;
198
+ const g = parseInt(hex.slice(3, 5), 16) * 257;
199
+ const b = parseInt(hex.slice(5, 7), 16) * 257;
200
200
  paragraph.color = [r, g, b];
201
201
  }
202
202
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iwork-mcp",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "MCP server for Apple iWork (Numbers, Pages, Keynote) automation",
5
5
  "license": "MIT",
6
6
  "type": "module",