@instructure/platform-notebook 0.2.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;EAKxB,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AAE7D,eAAO,MAAM,oBAAoB;;;;;;;;;EAG/B,CAAA;AACF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAE3E,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMxB,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AAI7D,oBAAY,aAAa;IACvB,SAAS,cAAc;IACvB,SAAS,cAAc;CACxB;AAED,eAAO,MAAM,YAAY,+DAA6D,CAAA;AAItF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;EAKnB,CAAA;AACF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAA;AAEnD,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,CAAA;AAIjD,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYf,CAAA;AACF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAA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AA;IACjB,QAAQ,EAAE,YAAY,CAAA;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,mBAAmB,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;IACzD,UAAU,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IACzD,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IACrE,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACtC;AAID,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB"}
@@ -0,0 +1,25 @@
1
+ import { TextPositionAnchor } from './TextPositionAnchor';
2
+ import { NoteType, TextPositionSelectorType, UpdateNoteInputType } from './types';
3
+ export declare const nodeTextLength: (node: Node) => number;
4
+ export declare const previousSiblingsTextLength: (node: Node) => number;
5
+ export declare const resolveOffsets: (element: Element, ...offsets: number[]) => Array<{
6
+ node: Text;
7
+ offset: number;
8
+ }>;
9
+ export declare const recalculateRangeFromPreviousTextPosition: (root: Element, selectedText: string, targetStart: number, targetEnd: number) => TextPositionAnchor | null;
10
+ export type TextSelectionPlacement = {
11
+ top: number;
12
+ left: number;
13
+ };
14
+ export type RecoverHighlightsResult = {
15
+ notesForUpdate: UpdateNoteInputType[];
16
+ noteIdsForDelete: string[];
17
+ };
18
+ export declare const recoverHighlights: (parentRef: Element, notes: NoteType[], pageLastModifiedAt: string) => RecoverHighlightsResult;
19
+ export declare const scrollToHighlight: (id: string) => void;
20
+ export declare const getPlacement: (range: Range) => TextSelectionPlacement | null;
21
+ export declare const isOverlapping: (newRange: TextPositionSelectorType, existingRanges: TextPositionSelectorType[]) => boolean;
22
+ export declare const createHighlightWrapperId: (id: string) => string;
23
+ export declare const createHighlightWrapperIdStart: (id: string) => string;
24
+ export declare const createHighlightWrapperIdEnd: (id: string) => string;
25
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAEtF,eAAO,MAAM,cAAc,GAAI,MAAM,IAAI,KAAG,MAQ3C,CAAA;AAED,eAAO,MAAM,0BAA0B,GAAI,MAAM,IAAI,KAAG,MAQvD,CAAA;AAED,eAAO,MAAM,cAAc,GACzB,SAAS,OAAO,EAChB,GAAG,SAAS,MAAM,EAAE,KACnB,KAAK,CAAC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CA8BtC,CAAA;AAmBD,eAAO,MAAM,wCAAwC,GACnD,MAAM,OAAO,EACb,cAAc,MAAM,EACpB,aAAa,MAAM,EACnB,WAAW,MAAM,KAChB,kBAAkB,GAAG,IAgDvB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,cAAc,EAAE,mBAAmB,EAAE,CAAA;IACrC,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAC3B,CAAA;AAcD,eAAO,MAAM,iBAAiB,GAC5B,WAAW,OAAO,EAClB,OAAO,QAAQ,EAAE,EACjB,oBAAoB,MAAM,KACzB,uBAsCF,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,IAAI,MAAM,KAAG,IAc9C,CAAA;AAKD,eAAO,MAAM,YAAY,GAAI,OAAO,KAAK,KAAG,sBAAsB,GAAG,IAmEpE,CAAA;AAED,eAAO,MAAM,aAAa,GACxB,UAAU,wBAAwB,EAClC,gBAAgB,wBAAwB,EAAE,KACzC,OAOF,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,IAAI,MAAM,KAAG,MAErD,CAAA;AAED,eAAO,MAAM,6BAA6B,GAAI,IAAI,MAAM,KAAG,MAE1D,CAAA;AAED,eAAO,MAAM,2BAA2B,GAAI,IAAI,MAAM,KAAG,MAExD,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const xpathFromNode: (node: Node, root: Node) => string | undefined;
2
+ export declare const nodeFromXPath: (xpath: string, root?: Element) => Node | null;
3
+ //# sourceMappingURL=xpath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xpath.d.ts","sourceRoot":"","sources":["../src/xpath.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,aAAa,GAAI,MAAM,IAAI,EAAE,MAAM,IAAI,uBAgBnD,CAAA;AA4DD,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,OAAM,OAAuB,KAAG,IAAI,GAAG,IAOnF,CAAA"}
@@ -0,0 +1,38 @@
1
+ {
2
+ "notebook": "Notebook",
3
+ "notes": "Notes",
4
+ "important": "Important",
5
+ "unclear": "Unclear",
6
+
7
+ "editNote": "Edit note",
8
+ "save": "Save",
9
+ "cancel": "Cancel",
10
+ "deleteNote": "Delete note",
11
+ "removeFromNotebook": "Remove from Notebook",
12
+ "addNoteOptional": "Add a note (optional).",
13
+ "markImportant": "Mark important",
14
+ "markUnclear": "Mark unclear",
15
+
16
+ "savedToNotebook": "Saved to Notebook.",
17
+ "noteUpdated": "Note updated",
18
+ "noteDeleted": "Note deleted",
19
+ "errorSavingNote": "Error saving to Notebook.",
20
+ "errorUpdatingNote": "Error updating note",
21
+ "noteDeletionFailed": "Note deletion failed",
22
+
23
+ "loadingNotes": "Loading notes",
24
+ "failedToLoadNotes": "Failed to load notes",
25
+ "emptyStateHeading": "Start capturing your notes",
26
+ "emptyStateDescription": "Your notes from learning materials will appear here. Highlight key ideas, reflections, or questions as you learn—they'll all be saved in your Notebook for easy review later.",
27
+ "nothingHereYet": "Nothing here yet",
28
+ "adjustFiltersOrCreate": "Adjust your filters or create a new note to get started.",
29
+ "noNotesForFilter": "You have no notes for the selected filter",
30
+
31
+ "previousPage": "Previous page",
32
+ "nextPage": "Next page",
33
+ "allCourses": "All courses",
34
+ "allNotes": "All notes",
35
+ "closeNotebookPanel": "Close Notebook panel",
36
+
37
+ "featureDescription": "To use the Notebook feature, highlight an excerpt from your learning material to flag it as 'confusing' or 'important' and leave an optional note."
38
+ }
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@instructure/platform-notebook",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./locales/en.json": "./locales/en.json"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "locales"
18
+ ],
19
+ "peerDependencies": {
20
+ "@instructure/ui": "^10.0.0",
21
+ "@tanstack/react-query": "^5.0.0",
22
+ "react": "^18.0.0",
23
+ "react-dom": "^18.0.0",
24
+ "styled-components": "^6.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@testing-library/jest-dom": "^6.9.1",
28
+ "@testing-library/react": "^16.0.0",
29
+ "@testing-library/user-event": "^14.0.0",
30
+ "@types/diff-match-patch": "^1.0.36",
31
+ "@types/react": "^18.3.0",
32
+ "@types/react-dom": "^18.3.0",
33
+ "@vitejs/plugin-react": "^4.0.0",
34
+ "@vitest/coverage-v8": "^4.0.17",
35
+ "jsdom": "^25.0.0",
36
+ "typescript": "^5.3.0",
37
+ "vite": "^6.0.0",
38
+ "vite-plugin-dts": "^4.0.0",
39
+ "vitest": "^4.0.0"
40
+ },
41
+ "dependencies": {
42
+ "diff-match-patch": "^1.0.5",
43
+ "zod": "^3.25.76"
44
+ },
45
+ "scripts": {
46
+ "build": "vite build",
47
+ "dev": "vite build --watch",
48
+ "test": "vitest run",
49
+ "test:watch": "vitest",
50
+ "test:coverage": "vitest run --coverage",
51
+ "lint": "biome check . && ast-grep scan . --report-style=short",
52
+ "lint:fix": "biome check --write .",
53
+ "type-check": "tsc -p tsconfig.check.json",
54
+ "pack:tarball": "pnpm build && pnpm pack"
55
+ }
56
+ }