Skip to content

Commit 4ddf1dd

Browse files
authored
Merge pull request #4929 from mmichaelush/feat/note-text-anchor
הערות אישיות: הערה על הספר, על שורות או על מילים, עורך מיקום, ו-API לתוספים
2 parents 24ad508 + 3e2f2c0 commit 4ddf1dd

48 files changed

Lines changed: 3680 additions & 248 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/plugin-sdk/API_REFERENCE.md‎

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ if (response.success) {
361361
| `notes.add` | 0.9.89 |
362362
| `notes.update` | 0.9.89 |
363363
| `notes.delete` | 0.9.89 |
364+
| `notes.setLocation` | 0.9.99 |
364365
| `ui.showMessage` | 0.9.89 |
365366
| `ui.showSuccess` | 0.9.89 |
366367
| `ui.showError` | 0.9.89 |
@@ -3438,6 +3439,17 @@ Otzaria.linkify(document.getElementById('note'));
34383439

34393440
## notes.* - הערות אישיות
34403441

3442+
להערה יש אחד משלושה סוגי מיקום (`scope`, מגרסה 0.9.99):
3443+
3444+
| `scope` | ההערה חלה על | שדות המיקום |
3445+
|---------|--------------|-------------|
3446+
| `'book'` | הספר כולו, בלי מיקום | — |
3447+
| `'lines'` | שורה אחת, או השורות `lineNumber`–`endLineNumber` | `lineNumber`, `endLineNumber` |
3448+
| `'words'` | מילים מסוימות בשורה אחת | `lineNumber`, `anchorText` |
3449+
3450+
`lineNumber` מתחיל מ-1, כלומר `sectionIndex + 1`. בספר PDF `lineNumber` הוא מספר
3451+
עמוד, ואין בו `'words'` ולא `endLineNumber`.
3452+
34413453
### `notes.list`
34423454
**הרשאה:** `notes.read`
34433455

@@ -3447,9 +3459,20 @@ Otzaria.linkify(document.getElementById('note'));
34473459
const { data } = await Otzaria.call('notes.list', {
34483460
bookId: 'בראשית'
34493461
});
3450-
// [{ id: "123", lineNumber: 5, content: "הערה...", contentPlain: "הערה..." }, ...]
3462+
// [{
3463+
// id: "pn_...", bookId: "בראשית",
3464+
// scope: "words", status: "located",
3465+
// lineNumber: 5, endLineNumber: null, anchorText: "ויאמר אלהים",
3466+
// content: "הערה...", contentPlain: "הערה...",
3467+
// createdAt: "2026-11-11T10:30:00.000", updatedAt: "2026-11-11T10:30:00.000"
3468+
// }, ...]
34513469
```
34523470

3471+
מגרסה 0.9.99 נוספו `bookId`, `scope`, `status`, `endLineNumber`, `anchorText`,
3472+
`createdAt` ו-`updatedAt`; במארח ישן הם חסרים. `status` הוא `'located'`,
3473+
`'missing'` (ההערה איבדה את מקומה כי הספר השתנה, ו-`lineNumber` הוא `null`) או
3474+
`'book'`. `anchorText` הן המילים בלי ניקוד ופיסוק, ו-`null` כשההערה אינה על מילים.
3475+
34533476
### `notes.getBookNotesSummary`
34543477
**הרשאה:** `notes.read`
34553478

@@ -3474,6 +3497,69 @@ const { data } = await Otzaria.call('notes.add', {
34743497
// true
34753498
```
34763499

3500+
**מיקום ההערה (מגרסה 0.9.99).** בלי הפרמטרים האלה ההערה חלה על השורה `lineNumber`
3501+
כולה, כמו קודם.
3502+
3503+
| פרמטר | פירוש |
3504+
|-------|-------|
3505+
| `scope` | `'book'` להערה על הספר כולו, בלי `lineNumber`. `'lines'` / `'words'` אופציונליים: הסוג נקבע לפי שאר הפרמטרים |
3506+
| `endLineNumber` | הערה על השורות `lineNumber`–`endLineNumber` |
3507+
| `range` | הערה על מילים: עוגן בשכבת `source`, כמו ב-`reader.setHighlight` — `sourceRange` של `reader.getSelection`, או `range` של `reader.findTextOccurrences` עם `layer: 'source'` |
3508+
| `text` | הערה על מילים: המילים עצמן. ההתאמה מתעלמת מניקוד, מטעמים ומפיסוק |
3509+
| `occurrence` | עם `text` בלבד: איזה מופע בשורה, מ-0. ברירת המחדל: הראשון |
3510+
| `returnNote` | `true` — מחזיר את ההערה שנוצרה (כמו ב-`notes.list`, כולל `id`) במקום `true` |
3511+
3512+
```javascript
3513+
const selection = (await Otzaria.call('reader.getSelection')).data;
3514+
const { data: note } = await Otzaria.call('notes.add', {
3515+
bookId: selection.bookId,
3516+
lineNumber: selection.sectionIndex + 1,
3517+
content: 'הערה על המילים שנבחרו',
3518+
range: selection.sourceRange,
3519+
returnNote: true
3520+
});
3521+
// note.id, note.scope === 'words'
3522+
3523+
await Otzaria.call('notes.add', {
3524+
bookId: 'בראשית', lineNumber: 1, content: 'על המופע השני', text: 'את', occurrence: 1
3525+
});
3526+
await Otzaria.call('notes.add', {
3527+
bookId: 'בראשית', lineNumber: 3, endLineNumber: 5, content: 'על שלוש שורות'
3528+
});
3529+
await Otzaria.call('notes.add', {
3530+
bookId: 'בראשית', scope: 'book', content: 'על הספר כולו'
3531+
});
3532+
```
3533+
3534+
שגיאות: `error.invalid_params` כשהפרמטרים סותרים (`range` וגם `text`, `scope: 'book'`
3535+
עם שורה, `endLineNumber` עם מילים או קטן מ-`lineNumber`), `range` לא תקין או בשכבה
3536+
אחרת, או שורה שאינה בספר. `error.not_found` כשהמילים אינן בשורה; ההערה לא נוצרת.
3537+
מארח ישן מתעלם מהפרמטרים ויוצר הערה על השורה כולה (או נכשל בלי `lineNumber`),
3538+
ולכן תוסף שתלוי בהם צריך `minAppVersion` של `0.9.99`.
3539+
3540+
### `notes.setLocation`
3541+
**הרשאה:** `notes.write`
3542+
3543+
**זמין מגרסה:** `0.9.99`
3544+
3545+
שינוי המיקום של הערה קיימת: העברה לשורות אחרות, למילים אחרות, או לספר כולו. התוכן
3546+
אינו משתנה. הפרמטרים כמו ב-`notes.add`, ובלי `scope` הסוג נקבע לפיהם. מחזיר את
3547+
ההערה המעודכנת, כמו ב-`notes.list`.
3548+
3549+
```javascript
3550+
const { data } = await Otzaria.call('notes.setLocation', {
3551+
bookId: 'בראשית',
3552+
noteId: 'pn_...',
3553+
lineNumber: 4,
3554+
text: 'ויאמר אלהים'
3555+
});
3556+
// { id: "pn_...", scope: "words", lineNumber: 4, anchorText: "ויאמר אלהים", ... }
3557+
3558+
await Otzaria.call('notes.setLocation', { bookId: 'בראשית', noteId: 'pn_...', scope: 'book' });
3559+
```
3560+
3561+
שגיאות: כמו ב-`notes.add`, ובנוסף `error.not_found` כשאין הערה כזו בספר.
3562+
34773563
### `notes.update`
34783564
**הרשאה:** `notes.write`
34793565

‎docs/plugin-sdk/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ Otzaria.on('plugin.boot', (payload) => {
522522
|--------|-------|----------|-------|
523523
| `notes.list` | `notes.read` | `{ bookId }` | `Note[]` |
524524
| `notes.getBookNotesSummary` | `notes.read` | — | `{ bookId, noteCount, lastModified }[]` |
525-
| `notes.add` | `notes.write` | `{ bookId, lineNumber, content }` | `boolean` |
525+
| `notes.add` | `notes.write` | `{ bookId, lineNumber?, content, scope?, endLineNumber?, range?, text?, occurrence?, returnNote? }` | `boolean` / `Note` |
526+
| `notes.setLocation` | `notes.write` | `{ bookId, noteId, scope?, lineNumber?, endLineNumber?, range?, text?, occurrence? }` | `Note` |
526527
| `notes.update` | `notes.write` | `{ bookId, noteId, content }` | `boolean` |
527528
| `notes.delete` | `notes.write` | `{ bookId, noteId }` | `boolean` |
528529

‎docs/plugin-sdk/otzaria_plugin.d.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,6 +2622,7 @@ export type OtzariaMethod =
26222622
| 'notes.add'
26232623
| 'notes.update'
26242624
| 'notes.delete'
2625+
| 'notes.setLocation'
26252626
| 'ui.showMessage'
26262627
| 'ui.showSuccess'
26272628
| 'ui.showError'

‎docs/plugin-sdk/spec.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
"notes.delete",
164164
"notes.getBookNotesSummary",
165165
"notes.list",
166+
"notes.setLocation",
166167
"notes.update",
167168
"notifications.cancel",
168169
"notifications.cancelAll",
@@ -333,6 +334,7 @@
333334
"notes.delete": "notes.write",
334335
"notes.getBookNotesSummary": "notes.read",
335336
"notes.list": "notes.read",
337+
"notes.setLocation": "notes.write",
336338
"notes.update": "notes.write",
337339
"notifications.cancel": "notifications.system",
338340
"notifications.cancelAll": "notifications.system",
@@ -508,6 +510,7 @@
508510
"notes.delete": "0.9.89",
509511
"notes.getBookNotesSummary": "0.9.89",
510512
"notes.list": "0.9.89",
513+
"notes.setLocation": "0.9.99",
511514
"notes.update": "0.9.89",
512515
"notifications.cancel": "0.9.89",
513516
"notifications.cancelAll": "0.9.89",

0 commit comments

Comments
 (0)