obsidian-typings 1.1.1 → 1.1.2

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.
Files changed (2) hide show
  1. package/obsidian-ex.d.ts +156 -148
  2. package/package.json +1 -1
package/obsidian-ex.d.ts CHANGED
@@ -851,6 +851,100 @@ declare module "obsidian" {
851
851
  vimMode?: false | boolean;
852
852
  }
853
853
 
854
+ /**
855
+ * @remark `BaseEditor` is never used in the Obsidian codebase, but is exposed in the Obsidian module as `Editor`.
856
+ * However, most editor components actually make use of the extended `Editor`, so this interface is purposely
857
+ * named to `BaseEditor` to not require any casting for most purposes (or overriding the `editor` property type
858
+ * for all components).
859
+ * @todo Potential risk of confusion when `Editor` is constructed from the Obsidian module, as it only has the
860
+ * methods from `BaseEditor`, *not* `Editor`
861
+ */
862
+ interface BaseEditor {
863
+ /**
864
+ * CodeMirror editor instance
865
+ */
866
+ cm: EditorView;
867
+ /**
868
+ * HTML instance the CM editor is attached to
869
+ */
870
+ containerEl: HTMLElement;
871
+
872
+ /**
873
+ * Clean-up function executed after indenting lists
874
+ */
875
+ afterIndent(): void;
876
+ /**
877
+ * Expand text
878
+ *
879
+ * @internal
880
+ */
881
+ expandText(): void;
882
+ /**
883
+ * Indents a list by one level
884
+ */
885
+ indentList(): void;
886
+ /**
887
+ * Insert a template callout at the current cursor position
888
+ */
889
+ insertCallout(): void;
890
+ /**
891
+ * Insert a template code block at the current cursor position
892
+ */
893
+ insertCodeblock(): void;
894
+ /**
895
+ * Insert a markdown link at the current cursor position
896
+ */
897
+ insertLink(): void;
898
+ /**
899
+ * Insert a mathjax equation block at the current cursor position
900
+ */
901
+ insertMathJax(): void;
902
+ /**
903
+ * Insert specified text at the current cursor position
904
+ *
905
+ * @remark Might be broken, inserts at the end of the document
906
+ */
907
+ insertText(text: string): void;
908
+ /**
909
+ * Inserts a new line and continues a markdown bullet point list at the same level
910
+ */
911
+ newlineAndIndentContinueMarkdownList(): void;
912
+ /**
913
+ * Inserts a new line at the same indent level
914
+ */
915
+ newlineAndIndentOnly(): void;
916
+ /**
917
+ * Get the character position at a mouse event
918
+ */
919
+ posAtMouse(e: MouseEvent): EditorPosition;
920
+ /**
921
+ * Toggles blockquote syntax on paragraph under cursor
922
+ */
923
+ toggleBlockquote(): void;
924
+ /**
925
+ * Toggle bullet point list syntax on paragraph under cursor
926
+ */
927
+ toggleBulletList(): void;
928
+ /**
929
+ * Toggle checkbox syntax on paragraph under cursor
930
+ */
931
+ toggleCheckList(): void;
932
+ /**
933
+ * Toggle numbered list syntax on paragraph under cursor
934
+ */
935
+ toggleNumberList(): void;
936
+ /**
937
+ * Convert word under cursor into a wikilink
938
+ *
939
+ * @param embed Whether to embed the link or not
940
+ */
941
+ triggerWikiLink(embed: boolean): void;
942
+ /**
943
+ * Unindents a list by one level
944
+ */
945
+ unindentList(): void;
946
+ }
947
+
854
948
  /** @todo Documentation incomplete */
855
949
  interface BlockCache {
856
950
  /**
@@ -1296,90 +1390,100 @@ declare module "obsidian" {
1296
1390
  fileBeingRenamed: null | TFile;
1297
1391
  }
1298
1392
 
1299
- interface Editor {
1300
- /**
1301
- * CodeMirror editor instance
1302
- */
1303
- cm: EditorView;
1304
- /**
1305
- * HTML instance the CM editor is attached to
1306
- */
1307
- containerEl: HTMLElement;
1308
-
1393
+ interface Editor extends BaseEditor {
1309
1394
  /**
1310
- * Clean-up function executed after indenting lists
1395
+ * Linked Editor manager instance
1311
1396
  */
1312
- afterIndent(): void;
1397
+ editorComponent: undefined | MarkdownScrollableEditView;
1313
1398
  /**
1314
- * Expand text
1399
+ * Currently active CM instance
1315
1400
  *
1316
- * @internal
1317
- */
1318
- expandText(): void;
1319
- /**
1320
- * Indents a list by one level
1401
+ * @remark Can be null when Editor is not instantiated
1321
1402
  */
1322
- indentList(): void;
1403
+ get activeCm(): EditorView | null;
1323
1404
  /**
1324
- * Insert a template callout at the current cursor position
1405
+ * Whether the editor is embedded in a table cell
1325
1406
  */
1326
- insertCallout(): void;
1407
+ get inTableCell(): boolean;
1408
+
1327
1409
  /**
1328
- * Insert a template code block at the current cursor position
1410
+ * Make ranges of text highlighted within the editor given specified class (style)
1329
1411
  */
1330
- insertCodeblock(): void;
1412
+ addHighlights(
1413
+ ranges: EditorRange[],
1414
+ style: "is-flashing" | "obsidian-search-match-highlight",
1415
+ remove_previous: boolean,
1416
+ range?: EditorSelection,
1417
+ ): void;
1331
1418
  /**
1332
- * Insert a markdown link at the current cursor position
1419
+ * Convert editor position to screen position
1420
+ *
1421
+ * @param pos Editor position
1422
+ * @param relative_to_editor Relative to the editor or the application window
1333
1423
  */
1334
- insertLink(): void;
1424
+ coordsAtPos(
1425
+ pos: EditorPosition,
1426
+ relative_to_editor: boolean,
1427
+ ): { left: number; top: number; bottom: number; right: number };
1335
1428
  /**
1336
- * Insert a mathjax equation block at the current cursor position
1429
+ * Unfolds all folded lines one level up
1430
+ *
1431
+ * @remark If level 1 and 2 headings are folded, level 2 headings will be unfolded
1337
1432
  */
1338
- insertMathJax(): void;
1433
+ foldLess(): void;
1339
1434
  /**
1340
- * Insert specified text at the current cursor position
1435
+ * Folds all the blocks that are of the lowest unfolded level
1341
1436
  *
1342
- * @remark Might be broken, inserts at the end of the document
1437
+ * @remark If there is a document with level 1 and 2 headings, level 2 headings will be folded
1343
1438
  */
1344
- insertText(text: string): void;
1439
+ foldMore(): void;
1345
1440
  /**
1346
- * Inserts a new line and continues a markdown bullet point list at the same level
1441
+ * Get all ranges that can be folded away in the editor
1347
1442
  */
1348
- newlineAndIndentContinueMarkdownList(): void;
1443
+ getAllFoldableLines(): { from: number; to: number }[];
1349
1444
  /**
1350
- * Inserts a new line at the same indent level
1445
+ * Get a clickable link - if it exists - at specified position
1351
1446
  */
1352
- newlineAndIndentOnly(): void;
1447
+ getClickableTokenAt(pos: EditorPosition): {
1448
+ start: EditorPosition;
1449
+ end: EditorPosition;
1450
+ text: string;
1451
+ type: string;
1452
+ } | null;
1353
1453
  /**
1354
- * Get the character position at a mouse event
1454
+ * Get all blocks that were folded by their starting character position
1355
1455
  */
1356
- posAtMouse(e: MouseEvent): EditorPosition;
1456
+ getFoldOffsets(): Set<number>;
1357
1457
  /**
1358
- * Toggles blockquote syntax on paragraph under cursor
1458
+ * Checks whether the editor has a highlight of specified class
1459
+ *
1460
+ * @remark If no style is specified, checks whether the editor has unknown highlights
1359
1461
  */
1360
- toggleBlockquote(): void;
1462
+ hasHighlight(style?: string): boolean;
1361
1463
  /**
1362
- * Toggle bullet point list syntax on paragraph under cursor
1464
+ * Wraps current line around specified characters
1465
+ *
1466
+ * @remark Was added in a recent Obsidian update (1.4.0 update cycle)
1363
1467
  */
1364
- toggleBulletList(): void;
1468
+ insertBlock(start: string, end: string): void;
1365
1469
  /**
1366
- * Toggle checkbox syntax on paragraph under cursor
1470
+ * Get the closest character position to the specified coordinates
1367
1471
  */
1368
- toggleCheckList(): void;
1472
+ posAtCoords(coords: { left: number; top: number }): EditorPosition;
1369
1473
  /**
1370
- * Toggle numbered list syntax on paragraph under cursor
1474
+ * Removes all highlights of specified class
1371
1475
  */
1372
- toggleNumberList(): void;
1476
+ removeHighlights(style: string): void;
1373
1477
  /**
1374
- * Convert word under cursor into a wikilink
1375
- *
1376
- * @param embed Whether to embed the link or not
1478
+ * Adds a search cursor to the editor
1377
1479
  */
1378
- triggerWikiLink(embed: boolean): void;
1480
+ searchCursor(searchString: string): SearchCursor;
1379
1481
  /**
1380
- * Unindents a list by one level
1482
+ * Applies specified markdown syntax to selected text or word under cursor
1381
1483
  */
1382
- unindentList(): void;
1484
+ toggleMarkdownFormatting(
1485
+ syntax: "bold" | "italic" | "strikethrough" | "highlight" | "code" | "math" | "comment",
1486
+ ): void;
1383
1487
  }
1384
1488
 
1385
1489
  interface EditorSearchComponent extends AbstractSearchComponent {
@@ -1390,7 +1494,7 @@ declare module "obsidian" {
1390
1494
  /**
1391
1495
  * Linked editor for search component
1392
1496
  */
1393
- editor: ExtendedEditor;
1497
+ editor: Editor;
1394
1498
  /**
1395
1499
  * Whether search component is currently rendering
1396
1500
  */
@@ -1714,102 +1818,6 @@ declare module "obsidian" {
1714
1818
  fn(...arg: unknown[]): void;
1715
1819
  }
1716
1820
 
1717
- interface ExtendedEditor extends Editor {
1718
- /**
1719
- * Linked Editor manager instance
1720
- */
1721
- editorComponent: undefined | MarkdownScrollableEditView;
1722
- /**
1723
- * Currently active CM instance
1724
- *
1725
- * @remark Can be null when Editor is not instantiated
1726
- */
1727
- get activeCm(): EditorView | null;
1728
- /**
1729
- * Whether the editor is embedded in a table cell
1730
- */
1731
- get inTableCell(): boolean;
1732
-
1733
- /**
1734
- * Make ranges of text highlighted within the editor given specified class (style)
1735
- */
1736
- addHighlights(
1737
- ranges: EditorRange[],
1738
- style: "is-flashing" | "obsidian-search-match-highlight",
1739
- remove_previous: boolean,
1740
- range?: EditorSelection,
1741
- ): void;
1742
- /**
1743
- * Convert editor position to screen position
1744
- *
1745
- * @param pos Editor position
1746
- * @param relative_to_editor Relative to the editor or the application window
1747
- */
1748
- coordsAtPos(
1749
- pos: EditorPosition,
1750
- relative_to_editor: boolean,
1751
- ): { left: number; top: number; bottom: number; right: number };
1752
- /**
1753
- * Unfolds all folded lines one level up
1754
- *
1755
- * @remark If level 1 and 2 headings are folded, level 2 headings will be unfolded
1756
- */
1757
- foldLess(): void;
1758
- /**
1759
- * Folds all the blocks that are of the lowest unfolded level
1760
- *
1761
- * @remark If there is a document with level 1 and 2 headings, level 2 headings will be folded
1762
- */
1763
- foldMore(): void;
1764
- /**
1765
- * Get all ranges that can be folded away in the editor
1766
- */
1767
- getAllFoldableLines(): { from: number; to: number }[];
1768
- /**
1769
- * Get a clickable link - if it exists - at specified position
1770
- */
1771
- getClickableTokenAt(pos: EditorPosition): {
1772
- start: EditorPosition;
1773
- end: EditorPosition;
1774
- text: string;
1775
- type: string;
1776
- } | null;
1777
- /**
1778
- * Get all blocks that were folded by their starting character position
1779
- */
1780
- getFoldOffsets(): Set<number>;
1781
- /**
1782
- * Checks whether the editor has a highlight of specified class
1783
- *
1784
- * @remark If no style is specified, checks whether the editor has unknown highlights
1785
- */
1786
- hasHighlight(style?: string): boolean;
1787
- /**
1788
- * Wraps current line around specified characters
1789
- *
1790
- * @remark Was added in a recent Obsidian update (1.4.0 update cycle)
1791
- */
1792
- insertBlock(start: string, end: string): void;
1793
- /**
1794
- * Get the closest character position to the specified coordinates
1795
- */
1796
- posAtCoords(coords: { left: number; top: number }): EditorPosition;
1797
- /**
1798
- * Removes all highlights of specified class
1799
- */
1800
- removeHighlights(style: string): void;
1801
- /**
1802
- * Adds a search cursor to the editor
1803
- */
1804
- searchCursor(searchString: string): SearchCursor;
1805
- /**
1806
- * Applies specified markdown syntax to selected text or word under cursor
1807
- */
1808
- toggleMarkdownFormatting(
1809
- syntax: "bold" | "italic" | "strikethrough" | "highlight" | "code" | "math" | "comment",
1810
- ): void;
1811
- }
1812
-
1813
1821
  interface FileCacheEntry {
1814
1822
  /**
1815
1823
  * Hash of file contents
@@ -2507,7 +2515,7 @@ declare module "obsidian" {
2507
2515
  *
2508
2516
  * @remark Handles formatting, table creation, highlight adding, etc.
2509
2517
  */
2510
- editor: ExtendedEditor;
2518
+ editor: Editor;
2511
2519
  /**
2512
2520
  * Element in which the CodeMirror editor resides
2513
2521
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "obsidian-typings",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Extended type definitions for the Obsidian API (https://obsidian.md)",
5
5
  "main": "",
6
6
  "types": "obsidian-ex.d.ts",