Commit aa70675
committed
feat(notion-fetch): add workaround for image hyperlinks via captions
Since Notion's "Add link" menu option doesn't expose hyperlinks via the
API, implement a workaround that detects URLs in image captions:
Method 1: Link annotations in caption rich_text
- Detects when URLs are formatted as links in captions
- Uses the link.url property from the rich_text annotation
Method 2: Plain text URL detection (NEW)
- Detects URLs typed as plain text in captions
- Uses regex to extract http(s) URLs: /https?:\/\/[^\s]+/
- Separates URL from alt text
Method 3 & 4: Future-proofing
- Checks for image.link and block.link properties
- Will work if Notion adds API support in the future
Users can now make images clickable by:
1. Typing a URL in the image caption (preferred workaround)
2. Pasting a link in the caption (Notion converts it automatically)
Note: The Notion UI "Add link" feature is not supported by the API.
Images using that feature will not have clickable links in the output.
Related to #961 parent 198da20 commit aa70675
1 file changed
+35
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | 350 | | |
359 | 351 | | |
360 | 352 | | |
| |||
363 | 355 | | |
364 | 356 | | |
365 | 357 | | |
366 | | - | |
| 358 | + | |
| 359 | + | |
367 | 360 | | |
368 | 361 | | |
369 | 362 | | |
370 | | - | |
| 363 | + | |
371 | 364 | | |
372 | 365 | | |
373 | | - | |
| 366 | + | |
374 | 367 | | |
375 | 368 | | |
376 | | - | |
377 | | - | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
378 | 373 | | |
379 | 374 | | |
380 | 375 | | |
381 | 376 | | |
382 | 377 | | |
383 | 378 | | |
384 | 379 | | |
385 | | - | |
| 380 | + | |
| 381 | + | |
386 | 382 | | |
387 | | - | |
| 383 | + | |
388 | 384 | | |
389 | 385 | | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
390 | 402 | | |
391 | 403 | | |
392 | 404 | | |
393 | | - | |
| 405 | + | |
394 | 406 | | |
395 | 407 | | |
396 | | - | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
397 | 411 | | |
398 | 412 | | |
399 | | - | |
| 413 | + | |
400 | 414 | | |
401 | 415 | | |
402 | | - | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
403 | 419 | | |
404 | 420 | | |
405 | 421 | | |
| |||
0 commit comments