notations 1.0.2 → 1.0.4

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 (68) hide show
  1. package/dist/notations.umd.js +3933 -12155
  2. package/dist/notations.umd.min.js +2 -3
  3. package/dist/notations.umd.min.js.map +1 -1
  4. package/lib/cjs/parser.js +1 -1
  5. package/lib/cjs/parser.js.map +1 -1
  6. package/lib/cjs/web/components/DockViewPlayground.d.ts +51 -0
  7. package/lib/cjs/web/components/DockViewPlayground.js +364 -0
  8. package/lib/cjs/web/components/DockViewPlayground.js.map +1 -0
  9. package/lib/cjs/web/components/NotationBlock.d.ts +35 -0
  10. package/lib/cjs/web/components/NotationBlock.js +219 -0
  11. package/lib/cjs/web/components/NotationBlock.js.map +1 -0
  12. package/lib/cjs/web/components/NotebookCell.d.ts +41 -0
  13. package/lib/cjs/web/components/NotebookCell.js +269 -0
  14. package/lib/cjs/web/components/NotebookCell.js.map +1 -0
  15. package/lib/cjs/web/components/NotebookView.d.ts +37 -0
  16. package/lib/cjs/web/components/NotebookView.js +379 -0
  17. package/lib/cjs/web/components/NotebookView.js.map +1 -0
  18. package/lib/cjs/web/components/SideBySideEditor.d.ts +47 -0
  19. package/lib/cjs/web/components/SideBySideEditor.js +171 -0
  20. package/lib/cjs/web/components/SideBySideEditor.js.map +1 -0
  21. package/lib/cjs/web/dockview.d.ts +2 -0
  22. package/lib/cjs/web/dockview.js +11 -0
  23. package/lib/cjs/web/dockview.js.map +1 -0
  24. package/lib/cjs/web/index.d.ts +8 -0
  25. package/lib/cjs/web/index.js +34 -0
  26. package/lib/cjs/web/index.js.map +1 -0
  27. package/lib/cjs/web/types/notebook.d.ts +64 -0
  28. package/lib/cjs/web/types/notebook.js +56 -0
  29. package/lib/cjs/web/types/notebook.js.map +1 -0
  30. package/lib/cjs/web/utils/cellFactory.d.ts +16 -0
  31. package/lib/cjs/web/utils/cellFactory.js +137 -0
  32. package/lib/cjs/web/utils/cellFactory.js.map +1 -0
  33. package/lib/cjs/web/utils/sourceSerializer.d.ts +19 -0
  34. package/lib/cjs/web/utils/sourceSerializer.js +162 -0
  35. package/lib/cjs/web/utils/sourceSerializer.js.map +1 -0
  36. package/lib/esm/parser.js +1 -1
  37. package/lib/esm/parser.js.map +1 -1
  38. package/lib/esm/web/components/DockViewPlayground.d.ts +51 -0
  39. package/lib/esm/web/components/DockViewPlayground.js +358 -0
  40. package/lib/esm/web/components/DockViewPlayground.js.map +1 -0
  41. package/lib/esm/web/components/NotationBlock.d.ts +35 -0
  42. package/lib/esm/web/components/NotationBlock.js +216 -0
  43. package/lib/esm/web/components/NotationBlock.js.map +1 -0
  44. package/lib/esm/web/components/NotebookCell.d.ts +41 -0
  45. package/lib/esm/web/components/NotebookCell.js +266 -0
  46. package/lib/esm/web/components/NotebookCell.js.map +1 -0
  47. package/lib/esm/web/components/NotebookView.d.ts +37 -0
  48. package/lib/esm/web/components/NotebookView.js +376 -0
  49. package/lib/esm/web/components/NotebookView.js.map +1 -0
  50. package/lib/esm/web/components/SideBySideEditor.d.ts +47 -0
  51. package/lib/esm/web/components/SideBySideEditor.js +168 -0
  52. package/lib/esm/web/components/SideBySideEditor.js.map +1 -0
  53. package/lib/esm/web/dockview.d.ts +2 -0
  54. package/lib/esm/web/dockview.js +3 -0
  55. package/lib/esm/web/dockview.js.map +1 -0
  56. package/lib/esm/web/index.d.ts +8 -0
  57. package/lib/esm/web/index.js +9 -0
  58. package/lib/esm/web/index.js.map +1 -0
  59. package/lib/esm/web/types/notebook.d.ts +64 -0
  60. package/lib/esm/web/types/notebook.js +50 -0
  61. package/lib/esm/web/types/notebook.js.map +1 -0
  62. package/lib/esm/web/utils/cellFactory.d.ts +16 -0
  63. package/lib/esm/web/utils/cellFactory.js +127 -0
  64. package/lib/esm/web/utils/cellFactory.js.map +1 -0
  65. package/lib/esm/web/utils/sourceSerializer.d.ts +19 -0
  66. package/lib/esm/web/utils/sourceSerializer.js +154 -0
  67. package/lib/esm/web/utils/sourceSerializer.js.map +1 -0
  68. package/package.json +41 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DockViewPlayground.js","sourceRoot":"","sources":["../../../../src/web/components/DockViewPlayground.ts"],"names":[],"mappings":";;;;;AAaA,iDAA6F;AAC7F,0EAA8E;AAoF9E,MAAM,cAAc,GAA6B;IAC/C,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,IAAI;IACnB,UAAU,EAAE,6BAA6B;IACzC,aAAa,EAAE,CAAC;IAChB,UAAU,EAAE,IAAI;CACjB,CAAC;AA4BF,MAAqB,kBAAkB;IAyBrC,YAAY,SAAsB,EAAE,SAAmC,EAAE;;QAjBjE,aAAQ,GAAuB,IAAI,CAAC;QAGpC,qBAAgB,GAA4B,IAAI,CAAC;QAGjD,kBAAa,GAAuB,IAAI,CAAC;QAGzC,mBAAc,GAAmB,EAAE,CAAC;QAS1C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,mCAAQ,cAAc,GAAK,MAAM,CAAE,CAAC;QAC/C,IAAI,CAAC,eAAe,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,WAAW,mCAAI,IAAI,CAAC;QAEvD,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IAKD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAKD,IAAI,MAAM;;QACR,OAAO,CAAA,MAAA,IAAI,CAAC,gBAAgB,0CAAE,MAAM,KAAI,EAAE,CAAC;IAC7C,CAAC;IAKD,IAAI,MAAM,CAAC,KAAa;QACtB,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,KAAK,CAAC;QACvC,CAAC;IACH,CAAC;IAKD,GAAG,CAAC,OAAe,EAAE,QAAsC,MAAM;QAC/D,MAAM,KAAK,GAAiB;YAC1B,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,K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AlgBD,qCAkgBC","sourcesContent":["/**\n * DockViewPlayground - A complete notation playground with DockView layout.\n *\n * Provides a ready-to-use playground experience with:\n * - Resizable editor panel\n * - Resizable notation output panel\n * - Optional console panel for logs/errors\n * - Layout persistence to localStorage\n * - Dark mode support\n *\n * Uses SideBySideEditor internally for editor/output management.\n */\n\nimport { DockviewComponent, DockviewApi, IContentRenderer, Parameters } from \"dockview-core\";\nimport SideBySideEditor, { SideBySideEditorConfig } from \"./SideBySideEditor\";\nimport { Notation } from \"../../notation\";\nimport { GlobalBeatLayout } from \"../../beats\";\n\n/**\n * Configuration for DockViewPlayground.\n */\nexport interface DockViewPlaygroundConfig {\n /**\n * Initial source text.\n */\n initialSource?: string;\n\n /**\n * Whether to show the console panel initially.\n * @default true\n */\n showConsole?: boolean;\n\n /**\n * Whether to persist layout to localStorage.\n * @default true\n */\n persistLayout?: boolean;\n\n /**\n * Storage key for layout persistence.\n * @default \"notations-playground-layout\"\n */\n storageKey?: string;\n\n /**\n * Layout version number. Increment to force layout reset when structure changes.\n * @default 1\n */\n layoutVersion?: number;\n\n /**\n * Whether to enable scroll synchronization between editor and output.\n * @default true\n */\n syncScroll?: boolean;\n\n /**\n * Optional markdown parser for RawBlock content.\n */\n markdownParser?: (content: string) => string;\n\n /**\n * SideBySideEditor configuration options.\n */\n editorConfig?: Partial<SideBySideEditorConfig>;\n\n /**\n * Callback when source changes.\n */\n onSourceChange?: (source: string) => void;\n\n /**\n * Callback when notation is successfully parsed.\n */\n onNotationParsed?: (notation: Notation, beatLayout: GlobalBeatLayout) => void;\n\n /**\n * Callback when parsing fails.\n */\n onParseError?: (errors: any[]) => void;\n\n /**\n * Function to detect dark mode. If not provided, checks for \"dark\" class on documentElement.\n */\n isDarkMode?: () => boolean;\n\n /**\n * CSS class for the editor textarea.\n */\n editorClass?: string;\n\n /**\n * CSS class for the output container.\n */\n outputClass?: string;\n}\n\nconst DEFAULT_CONFIG: DockViewPlaygroundConfig = {\n showConsole: true,\n persistLayout: true,\n storageKey: \"notations-playground-layout\",\n layoutVersion: 1,\n syncScroll: true,\n};\n\n/**\n * Console log entry.\n */\ninterface ConsoleEntry {\n timestamp: Date;\n level: \"info\" | \"error\" | \"warning\";\n message: string;\n}\n\n/**\n * DockViewPlayground creates a complete notation playground with DockView layout.\n *\n * Usage:\n * ```typescript\n * const playground = new DockViewPlayground(container, {\n * initialSource: \"s r g m p\",\n * onSourceChange: (source) => console.log(\"Source:\", source),\n * });\n *\n * // Access the SideBySideEditor\n * playground.editor.source = \"new source\";\n *\n * // Log to console panel\n * playground.log(\"Hello!\", \"info\");\n * ```\n */\nexport default class DockViewPlayground {\n /** The container element */\n readonly container: HTMLElement;\n\n /** Configuration */\n readonly config: DockViewPlaygroundConfig;\n\n /** DockView API */\n private dockview: DockviewApi | null = null;\n\n /** SideBySideEditor instance */\n private sideBySideEditor: SideBySideEditor | null = null;\n\n /** Console output element */\n private consoleOutput: HTMLElement | null = null;\n\n /** Console entries */\n private consoleEntries: ConsoleEntry[] = [];\n\n /**\n * Creates a new DockViewPlayground.\n *\n * @param container The container element for the playground\n * @param config Configuration options\n */\n constructor(container: HTMLElement, config: DockViewPlaygroundConfig = {}) {\n this.container = container;\n this.config = { ...DEFAULT_CONFIG, ...config };\n this._consoleVisible = this.config.showConsole ?? true;\n\n this.init();\n }\n\n /**\n * Gets the SideBySideEditor instance.\n */\n get editor(): SideBySideEditor | null {\n return this.sideBySideEditor;\n }\n\n /**\n * Gets the current source.\n */\n get source(): string {\n return this.sideBySideEditor?.source || \"\";\n }\n\n /**\n * Sets the source and re-renders.\n */\n set source(value: string) {\n if (this.sideBySideEditor) {\n this.sideBySideEditor.source = value;\n }\n }\n\n /**\n * Logs a message to the console panel.\n */\n log(message: string, level: \"info\" | \"error\" | \"warning\" = \"info\"): void {\n const entry: ConsoleEntry = {\n timestamp: new Date(),\n level,\n message,\n };\n this.consoleEntries.push(entry);\n this.renderConsoleEntry(entry);\n }\n\n /**\n * Clears the console.\n */\n clearConsole(): void {\n this.consoleEntries = [];\n if (this.consoleOutput) {\n this.consoleOutput.innerHTML = \"\";\n }\n }\n\n /**\n * Renders the notation manually.\n */\n render(): boolean {\n return this.sideBySideEditor?.render() || false;\n }\n\n /**\n * Destroys the playground and cleans up resources.\n */\n destroy(): void {\n this.sideBySideEditor?.destroy();\n this.dockview?.dispose();\n this.container.innerHTML = \"\";\n }\n\n /**\n * Resets the layout to defaults.\n * Clears persisted layout and recreates the default layout.\n */\n resetLayout(): void {\n if (this.config.storageKey) {\n localStorage.removeItem(this.config.storageKey);\n }\n if (this.dockview) {\n this.dockview.clear();\n this.createDefaultLayout();\n }\n }\n\n // Console visibility API\n\n /** Whether the console is currently visible */\n private _consoleVisible: boolean;\n\n /**\n * Returns whether the console panel is currently visible.\n */\n isConsoleVisible(): boolean {\n return this._consoleVisible;\n }\n\n /**\n * Shows the console panel.\n */\n showConsole(): void {\n if (this._consoleVisible || !this.dockview) return;\n\n // Add console below editor (spans full width at bottom)\n this.dockview.addPanel({\n id: \"console\",\n component: \"console\",\n title: \"Console\",\n position: { direction: \"below\", referencePanel: \"editor\" },\n });\n\n // Set console to ~10% height\n const consolePanel = this.dockview.getPanel(\"console\");\n const containerHeight = this.container.clientHeight || 600;\n if (consolePanel?.group?.api) {\n consolePanel.group.api.setSize({ height: Math.floor(containerHeight * 0.1) });\n }\n\n this._consoleVisible = true;\n }\n\n /**\n * Hides the console panel.\n */\n hideConsole(): void {\n if (!this._consoleVisible || !this.dockview) return;\n\n const consolePanel = this.dockview.getPanel(\"console\");\n if (consolePanel) {\n consolePanel.api.close();\n }\n this._consoleVisible = false;\n }\n\n /**\n * Toggles the console panel visibility.\n * @returns The new visibility state.\n */\n toggleConsole(): boolean {\n if (this._consoleVisible) {\n this.hideConsole();\n } else {\n this.showConsole();\n }\n return this._consoleVisible;\n }\n\n /**\n * Initializes the playground.\n */\n private init(): void {\n // Ensure container has proper sizing for DockView\n // DockView requires explicit height on its container\n if (!this.container.style.height && !this.container.offsetHeight) {\n this.container.style.height = \"100%\";\n }\n this.container.style.width = this.container.style.width || \"100%\";\n\n // Apply theme class (preserve existing classes)\n const isDark = this.isDarkMode();\n this.container.classList.add(isDark ? \"dockview-theme-dark\" : \"dockview-theme-light\");\n\n // Watch for theme changes\n const observer = new MutationObserver(() => {\n const dark = this.isDarkMode();\n this.container.classList.remove(\"dockview-theme-dark\", \"dockview-theme-light\");\n this.container.classList.add(dark ? \"dockview-theme-dark\" : \"dockview-theme-light\");\n });\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"class\"],\n });\n\n // Create DockView\n const dockviewComponent = new DockviewComponent(this.container, {\n createComponent: (options) => this.createComponent(options),\n });\n\n this.dockview = dockviewComponent.api;\n\n // Try to restore saved layout, otherwise create default\n if (!this.config.persistLayout || !this.loadLayout()) {\n this.createDefaultLayout();\n }\n\n // Listen for layout changes to persist them\n if (this.config.persistLayout) {\n this.dockview.onDidLayoutChange(() => {\n this.saveLayout();\n });\n }\n\n this.log(\"Playground initialized\", \"info\");\n }\n\n /**\n * Checks if dark mode is active.\n */\n private isDarkMode(): boolean {\n if (this.config.isDarkMode) {\n return this.config.isDarkMode();\n }\n return document.documentElement.classList.contains(\"dark\");\n }\n\n /**\n * Saves the layout to localStorage.\n */\n private saveLayout(): void {\n if (!this.dockview || !this.config.storageKey) return;\n try {\n const layout = this.dockview.toJSON();\n const data = {\n version: this.config.layoutVersion,\n layout,\n };\n localStorage.setItem(this.config.storageKey, JSON.stringify(data));\n } catch (e) {\n console.warn(\"Failed to save layout:\", e);\n }\n }\n\n /**\n * Loads the layout from localStorage.\n */\n private loadLayout(): boolean {\n if (!this.dockview || !this.config.storageKey) return false;\n try {\n const saved = localStorage.getItem(this.config.storageKey);\n if (saved) {\n const data = JSON.parse(saved);\n // Check version - if outdated or missing, reset to defaults\n if (data.version !== this.config.layoutVersion) {\n localStorage.removeItem(this.config.storageKey);\n return false;\n }\n this.dockview.fromJSON(data.layout);\n return true;\n }\n } catch (e) {\n console.warn(\"Failed to load layout:\", e);\n if (this.config.storageKey) {\n localStorage.removeItem(this.config.storageKey);\n }\n }\n return false;\n }\n\n /**\n * Creates a component for DockView.\n */\n private createComponent(options: any): IContentRenderer {\n switch (options.name) {\n case \"editor\":\n return this.createEditorPanel();\n case \"output\":\n return this.createOutputPanel();\n case \"console\":\n return this.createConsolePanel();\n default:\n return {\n element: document.createElement(\"div\"),\n init: () => {},\n };\n }\n }\n\n /**\n * Creates the default layout.\n * Layout: Editor and Output side by side on top (80% height),\n * Console spanning full width on bottom (20% height).\n */\n private createDefaultLayout(): void {\n if (!this.dockview) return;\n\n // Get container dimensions for proportional sizing\n const containerHeight = this.container.clientHeight || 600;\n const containerWidth = this.container.clientWidth || 800;\n\n // Editor panel (top left)\n this.dockview.addPanel({\n id: \"editor\",\n component: \"editor\",\n title: \"Editor\",\n });\n\n // Console panel (bottom, full width) - add BEFORE output\n // so it creates a vertical split at the root level\n if (this._consoleVisible) {\n this.dockview.addPanel({\n id: \"console\",\n component: \"console\",\n title: \"Console\",\n position: { direction: \"below\", referencePanel: \"editor\" },\n });\n }\n\n // Output panel (top right) - splits the top row\n this.dockview.addPanel({\n id: \"output\",\n component: \"output\",\n title: \"Notation Output\",\n position: { direction: \"right\", referencePanel: \"editor\" },\n });\n\n // Set sizes using the group API\n const editorPanel = this.dockview.getPanel(\"editor\");\n const consolePanel = this.dockview.getPanel(\"console\");\n const outputPanel = this.dockview.getPanel(\"output\");\n\n // Set console height to ~10% of container\n if (consolePanel?.group?.api) {\n consolePanel.group.api.setSize({ height: Math.floor(containerHeight * 0.1) });\n }\n\n // Set editor and output to 50% width each\n if (editorPanel?.group?.api) {\n editorPanel.group.api.setSize({ width: Math.floor(containerWidth * 0.5) });\n }\n if (outputPanel?.group?.api) {\n outputPanel.group.api.setSize({ width: Math.floor(containerWidth * 0.5) });\n }\n }\n\n /**\n * Creates the editor panel.\n */\n private createEditorPanel(): IContentRenderer {\n const element = document.createElement(\"div\");\n element.className = \"dvp-panel dvp-editor-panel\";\n element.style.cssText = \"display: flex; flex-direction: column; height: 100%; padding: 0.5rem;\";\n\n return {\n element,\n init: (_params: Parameters) => {\n // Create SideBySideEditor config\n const editorConfig: SideBySideEditorConfig = {\n initialSource: this.config.initialSource,\n debounceDelay: 300,\n syncScroll: this.config.syncScroll,\n markdownParser: this.config.markdownParser,\n ...this.config.editorConfig,\n onSourceChange: (source) => {\n this.log(`Source changed (${source.length} chars)`, \"info\");\n this.config.onSourceChange?.(source);\n this.config.editorConfig?.onSourceChange?.(source);\n },\n onNotationParsed: (notation, beatLayout) => {\n const lineCount = beatLayout.gridModelsForLine.size;\n this.log(`Parsed: ${lineCount} line${lineCount !== 1 ? \"s\" : \"\"}`, \"info\");\n this.config.onNotationParsed?.(notation, beatLayout);\n this.config.editorConfig?.onNotationParsed?.(notation, beatLayout);\n },\n onParseError: (errors) => {\n errors.forEach((e) => {\n this.log(`Parse error: ${e.message || e}`, \"error\");\n });\n this.config.onParseError?.(errors);\n this.config.editorConfig?.onParseError?.(errors);\n },\n editorClass: this.config.editorClass,\n };\n\n // Create the editor\n this.sideBySideEditor = new SideBySideEditor(editorConfig);\n\n // Style the editor element\n const editorEl = this.sideBySideEditor.editorElement;\n editorEl.style.cssText = `\n width: 100%;\n height: 100%;\n resize: none;\n font-family: \"SF Mono\", \"Monaco\", \"Inconsolata\", \"Fira Code\", monospace;\n font-size: 14px;\n padding: 0.5rem;\n border: 1px solid var(--dv-separator-border, #ddd);\n border-radius: 4px;\n outline: none;\n `;\n\n element.appendChild(editorEl);\n },\n };\n }\n\n /**\n * Creates the output panel.\n */\n private createOutputPanel(): IContentRenderer {\n const element = document.createElement(\"div\");\n element.className = \"dvp-panel dvp-output-panel\";\n element.style.cssText = \"display: flex; flex-direction: column; height: 100%;\";\n\n return {\n element,\n init: (_params: Parameters) => {\n if (this.sideBySideEditor) {\n // Style the output element\n const outputEl = this.sideBySideEditor.outputElement;\n outputEl.style.cssText = `\n width: 100%;\n height: 100%;\n overflow: auto;\n padding: 1rem;\n `;\n\n element.appendChild(outputEl);\n }\n },\n };\n }\n\n /**\n * Creates the console panel.\n */\n private createConsolePanel(): IContentRenderer {\n const element = document.createElement(\"div\");\n element.className = \"dvp-panel dvp-console-panel\";\n element.style.cssText = \"display: flex; flex-direction: column; height: 100%;\";\n\n return {\n element,\n init: (_params: Parameters) => {\n // Console header\n const header = document.createElement(\"div\");\n header.className = \"dvp-console-header\";\n header.style.cssText = `\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0.25rem 0.5rem;\n font-size: 0.75rem;\n `;\n\n const clearBtn = document.createElement(\"button\");\n clearBtn.className = \"dvp-console-clear-btn\";\n clearBtn.textContent = \"Clear\";\n clearBtn.style.cssText = `\n padding: 0.125rem 0.5rem;\n font-size: 0.75rem;\n border-radius: 3px;\n cursor: pointer;\n `;\n clearBtn.onclick = () => this.clearConsole();\n header.appendChild(clearBtn);\n\n element.appendChild(header);\n\n // Console output\n this.consoleOutput = document.createElement(\"div\");\n this.consoleOutput.className = \"dvp-console-output\";\n this.consoleOutput.style.cssText = `\n flex: 1;\n overflow: auto;\n padding: 0.5rem;\n font-family: \"SF Mono\", \"Monaco\", \"Inconsolata\", monospace;\n font-size: 0.75rem;\n `;\n element.appendChild(this.consoleOutput);\n\n // Re-render existing entries\n this.consoleEntries.forEach((entry) => this.renderConsoleEntry(entry));\n },\n };\n }\n\n /**\n * Renders a console entry.\n */\n private renderConsoleEntry(entry: ConsoleEntry): void {\n if (!this.consoleOutput) return;\n\n const line = document.createElement(\"div\");\n line.style.cssText = `\n padding: 0.125rem 0;\n border-bottom: 1px solid var(--dv-separator-border, rgba(0,0,0,0.1));\n `;\n\n if (entry.level === \"error\") {\n line.style.color = \"#f44336\";\n } else if (entry.level === \"warning\") {\n line.style.color = \"#ff9800\";\n }\n\n const time = entry.timestamp.toLocaleTimeString();\n line.textContent = `[${time}] ${entry.message}`;\n\n this.consoleOutput.appendChild(line);\n this.consoleOutput.scrollTop = this.consoleOutput.scrollHeight;\n }\n}\n"]}
@@ -0,0 +1,35 @@
1
+ import { NotationView } from "../../carnatic";
2
+ export interface NotationBlockConfig {
3
+ createViewer: (container: HTMLDivElement) => NotationView;
4
+ cssClasses?: {
5
+ root?: string;
6
+ sourceContainer?: string;
7
+ sourceCaption?: string;
8
+ sourceCode?: string;
9
+ outputLabel?: string;
10
+ outputContainer?: string;
11
+ };
12
+ }
13
+ export default class NotationBlock {
14
+ readonly container: HTMLElement;
15
+ readonly config: NotationBlockConfig;
16
+ id: string;
17
+ source: string;
18
+ caption: string;
19
+ height: string;
20
+ newRoot: HTMLDivElement;
21
+ notationView: NotationView;
22
+ showSource: boolean;
23
+ isEditing: boolean;
24
+ editTextarea: HTMLTextAreaElement | null;
25
+ sourceCodeElement: HTMLElement | null;
26
+ constructor(container: HTMLElement, config: NotationBlockConfig);
27
+ updatePreview(): void;
28
+ get captionId(): string;
29
+ copyToClipboard(): Promise<void>;
30
+ toggleEditMode(): void;
31
+ enterEditMode(): void;
32
+ exitEditMode(): void;
33
+ applyEdit(): void;
34
+ cancelEdit(): void;
35
+ }
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const loader_1 = require("../../loader");
13
+ class NotationBlock {
14
+ constructor(container, config) {
15
+ var _a, _b, _c, _d, _e, _f;
16
+ this.container = container;
17
+ this.config = config;
18
+ this.caption = "";
19
+ this.isEditing = false;
20
+ this.editTextarea = null;
21
+ this.sourceCodeElement = null;
22
+ this.id = (container.getAttribute("id") || "").trim();
23
+ this.caption = (container.getAttribute("caption") || "").trim();
24
+ const sourceFrom = (container.getAttribute("sourceFrom") || "").trim();
25
+ this.source = container.textContent || "";
26
+ if (sourceFrom.length > 0) {
27
+ const sourceElem = document.getElementById(sourceFrom);
28
+ if (sourceElem) {
29
+ this.source = sourceElem.textContent || "";
30
+ }
31
+ }
32
+ this.height = container.getAttribute("height") || "";
33
+ this.showSource = (container.getAttribute("showSource") || "false") == "true";
34
+ const parent = container.parentNode;
35
+ const newRoot = document.createElement("div");
36
+ newRoot.classList.add("notationBlockRoot");
37
+ if ((_a = config.cssClasses) === null || _a === void 0 ? void 0 : _a.root) {
38
+ newRoot.className += " " + config.cssClasses.root;
39
+ }
40
+ this.newRoot = newRoot;
41
+ let html = "";
42
+ if (this.showSource) {
43
+ const sourceLines = this.source.split("\n");
44
+ const sourceClass = ((_b = config.cssClasses) === null || _b === void 0 ? void 0 : _b.sourceContainer) || "";
45
+ const captionClass = ((_c = config.cssClasses) === null || _c === void 0 ? void 0 : _c.sourceCaption) || "";
46
+ const codeClass = ((_d = config.cssClasses) === null || _d === void 0 ? void 0 : _d.sourceCode) || "";
47
+ html += `
48
+ <figure class="notation-source-block ${sourceClass}">
49
+ <div class="notation-source-header">
50
+ <figcaption class="notation-caption ${captionClass}">${this.caption}</figcaption>
51
+ <div class="notation-source-actions">
52
+ <button class="notation-btn notation-copy-btn" id="copyBtn_${this.id}" title="Copy to clipboard">
53
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
54
+ <path d="M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V2zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H6zM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1H2z"/>
55
+ </svg>
56
+ <span class="notation-btn-text">Copy</span>
57
+ </button>
58
+ <button class="notation-btn notation-edit-btn" id="editBtn_${this.id}" title="Edit notation">
59
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
60
+ <path d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z"/>
61
+ </svg>
62
+ <span class="notation-btn-text">Edit</span>
63
+ </button>
64
+ </div>
65
+ </div>
66
+ <div class="notation-source" id="notationSource_${this.id}">
67
+ <pre class="notation-source-pre">
68
+ <code class="${codeClass}" id="sourceCode_${this.id}">${sourceLines.map((x) => `<span>${x}</span>`).join("\n")}</code>
69
+ </pre>
70
+ <textarea class="notation-edit-textarea" id="editTextarea_${this.id}" style="display: none;"></textarea>
71
+ </div>
72
+ <div class="notation-edit-actions" id="editActions_${this.id}" style="display: none;">
73
+ <button class="notation-btn notation-apply-btn" id="applyBtn_${this.id}">Apply</button>
74
+ <button class="notation-btn notation-cancel-btn" id="cancelBtn_${this.id}">Cancel</button>
75
+ </div>
76
+ </figure>`;
77
+ }
78
+ const outputLabelClass = ((_e = config.cssClasses) === null || _e === void 0 ? void 0 : _e.outputLabel) || "";
79
+ const outputClass = ((_f = config.cssClasses) === null || _f === void 0 ? void 0 : _f.outputContainer) || "";
80
+ html += `
81
+ <div class="notation-output">
82
+ <span class="notation-output-label ${outputLabelClass}"><strong>Output:</strong></span>
83
+ <div id="notationViewer_${this.id}" class="notation-view ${outputClass}">
84
+ </div>
85
+ </div>`;
86
+ newRoot.innerHTML = html;
87
+ parent.insertBefore(newRoot, container);
88
+ parent.removeChild(container);
89
+ const notationViewerBlock = newRoot.querySelector(".notation-view");
90
+ this.notationView = config.createViewer(notationViewerBlock);
91
+ if (this.showSource) {
92
+ this.sourceCodeElement = newRoot.querySelector(`#sourceCode_${this.id}`);
93
+ this.editTextarea = newRoot.querySelector(`#editTextarea_${this.id}`);
94
+ const copyBtn = newRoot.querySelector(`#copyBtn_${this.id}`);
95
+ if (copyBtn) {
96
+ copyBtn.addEventListener("click", () => this.copyToClipboard());
97
+ }
98
+ const editBtn = newRoot.querySelector(`#editBtn_${this.id}`);
99
+ if (editBtn) {
100
+ editBtn.addEventListener("click", () => this.toggleEditMode());
101
+ }
102
+ const applyBtn = newRoot.querySelector(`#applyBtn_${this.id}`);
103
+ if (applyBtn) {
104
+ applyBtn.addEventListener("click", () => this.applyEdit());
105
+ }
106
+ const cancelBtn = newRoot.querySelector(`#cancelBtn_${this.id}`);
107
+ if (cancelBtn) {
108
+ cancelBtn.addEventListener("click", () => this.cancelEdit());
109
+ }
110
+ }
111
+ this.updatePreview();
112
+ console.log("Done Rendering... Adjusting height");
113
+ }
114
+ updatePreview() {
115
+ const fullContents = this.source;
116
+ this.notationView.tableElement.innerHTML = "";
117
+ const [notation, beatLayout, errors, timings] = (0, loader_1.load)(fullContents, { log: true });
118
+ if (errors.length > 0) {
119
+ console.log("Errors: ", errors);
120
+ }
121
+ else {
122
+ console.log("Rendering notation...");
123
+ this.notationView.renderNotation(notation, beatLayout);
124
+ }
125
+ const msg = `Document parsed (${Math.trunc(timings.parseTime * 100) / 100} ms) and built (${Math.trunc(timings.buildTime * 100) / 100} ms)`;
126
+ console.log(msg);
127
+ }
128
+ get captionId() {
129
+ return "notationCaption_" + this.id;
130
+ }
131
+ copyToClipboard() {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ try {
134
+ yield navigator.clipboard.writeText(this.source);
135
+ const copyBtn = this.newRoot.querySelector(`#copyBtn_${this.id}`);
136
+ if (copyBtn) {
137
+ const btnText = copyBtn.querySelector(".notation-btn-text");
138
+ const originalText = btnText === null || btnText === void 0 ? void 0 : btnText.textContent;
139
+ if (btnText) {
140
+ btnText.textContent = "Copied!";
141
+ setTimeout(() => {
142
+ if (btnText)
143
+ btnText.textContent = originalText || "Copy";
144
+ }, 2000);
145
+ }
146
+ }
147
+ }
148
+ catch (err) {
149
+ console.error("Failed to copy to clipboard:", err);
150
+ alert("Failed to copy to clipboard");
151
+ }
152
+ });
153
+ }
154
+ toggleEditMode() {
155
+ this.isEditing = !this.isEditing;
156
+ if (this.isEditing) {
157
+ this.enterEditMode();
158
+ }
159
+ else {
160
+ this.exitEditMode();
161
+ }
162
+ }
163
+ enterEditMode() {
164
+ if (!this.editTextarea || !this.sourceCodeElement)
165
+ return;
166
+ this.editTextarea.value = this.source;
167
+ if (this.sourceCodeElement.parentElement) {
168
+ this.sourceCodeElement.parentElement.style.display = "none";
169
+ }
170
+ this.editTextarea.style.display = "block";
171
+ this.editTextarea.style.height = "auto";
172
+ this.editTextarea.style.height = this.editTextarea.scrollHeight + "px";
173
+ const editActions = this.newRoot.querySelector(`#editActions_${this.id}`);
174
+ if (editActions) {
175
+ editActions.style.display = "flex";
176
+ }
177
+ const editBtn = this.newRoot.querySelector(`#editBtn_${this.id}`);
178
+ const btnText = editBtn === null || editBtn === void 0 ? void 0 : editBtn.querySelector(".notation-btn-text");
179
+ if (btnText) {
180
+ btnText.textContent = "Editing...";
181
+ }
182
+ this.editTextarea.focus();
183
+ }
184
+ exitEditMode() {
185
+ if (!this.editTextarea || !this.sourceCodeElement)
186
+ return;
187
+ this.editTextarea.style.display = "none";
188
+ if (this.sourceCodeElement.parentElement) {
189
+ this.sourceCodeElement.parentElement.style.display = "block";
190
+ }
191
+ const editActions = this.newRoot.querySelector(`#editActions_${this.id}`);
192
+ if (editActions) {
193
+ editActions.style.display = "none";
194
+ }
195
+ const editBtn = this.newRoot.querySelector(`#editBtn_${this.id}`);
196
+ const btnText = editBtn === null || editBtn === void 0 ? void 0 : editBtn.querySelector(".notation-btn-text");
197
+ if (btnText) {
198
+ btnText.textContent = "Edit";
199
+ }
200
+ }
201
+ applyEdit() {
202
+ if (!this.editTextarea)
203
+ return;
204
+ this.source = this.editTextarea.value;
205
+ if (this.sourceCodeElement) {
206
+ const sourceLines = this.source.split("\n");
207
+ this.sourceCodeElement.innerHTML = sourceLines.map((x) => `<span>${x}</span>`).join("\n");
208
+ }
209
+ this.updatePreview();
210
+ this.isEditing = false;
211
+ this.exitEditMode();
212
+ }
213
+ cancelEdit() {
214
+ this.isEditing = false;
215
+ this.exitEditMode();
216
+ }
217
+ }
218
+ exports.default = NotationBlock;
219
+ //# sourceMappingURL=NotationBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotationBlock.js","sourceRoot":"","sources":["../../../../src/web/components/NotationBlock.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,yCAAoC;AAkBpC,MAAqB,aAAa;IAYhC,YACkB,SAAsB,EACtB,MAA2B;;QAD3B,cAAS,GAAT,SAAS,CAAa;QACtB,WAAM,GAAN,MAAM,CAAqB;QAX7C,YAAO,GAAG,EAAE,CAAC;QAKb,cAAS,GAAG,KAAK,CAAC;QAClB,iBAAY,GAA+B,IAAI,CAAC;QAChD,sBAAiB,GAAuB,IAAI,CAAC;QAM3C,IAAI,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACtD,IAAI,CAAC,OAAO,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAChE,MAAM,UAAU,GAAG,CAAC,SAAS,CAAC,Y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AAE,CAAC;YACZ,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,SAAS;QACP,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,OAAO;QAG/B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;QAGtC,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,CAAC,iBAAiB,CAAC,SAAS,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5F,CAAC;QAGD,IAAI,CAAC,aAAa,EAAE,CAAC;QAGrB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAED,UAAU;QAER,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;CACF;AA3QD,gCA2QC","sourcesContent":["import { load } from \"../../loader\";\nimport { NotationView } from \"../../carnatic\";\n\nexport interface NotationBlockConfig {\n /** Function to create a notation viewer - allows different implementations */\n createViewer: (container: HTMLDivElement) => NotationView;\n\n /** CSS classes to apply to various elements */\n cssClasses?: {\n root?: string;\n sourceContainer?: string;\n sourceCaption?: string;\n sourceCode?: string;\n outputLabel?: string;\n outputContainer?: string;\n };\n}\n\nexport default class NotationBlock {\n id: string;\n source: string;\n caption = \"\";\n height: string;\n newRoot: HTMLDivElement;\n notationView: NotationView;\n showSource: boolean;\n isEditing = false;\n editTextarea: HTMLTextAreaElement | null = null;\n sourceCodeElement: HTMLElement | null = null;\n\n constructor(\n public readonly container: HTMLElement,\n public readonly config: NotationBlockConfig,\n ) {\n this.id = (container.getAttribute(\"id\") || \"\").trim();\n this.caption = (container.getAttribute(\"caption\") || \"\").trim();\n const sourceFrom = (container.getAttribute(\"sourceFrom\") || \"\").trim();\n this.source = container.textContent || \"\";\n\n if (sourceFrom.length > 0) {\n const sourceElem = document.getElementById(sourceFrom);\n if (sourceElem) {\n this.source = sourceElem.textContent || \"\";\n }\n }\n\n this.height = container.getAttribute(\"height\") || \"\";\n this.showSource = (container.getAttribute(\"showSource\") || \"false\") == \"true\";\n\n const parent = container.parentNode as HTMLDivElement;\n const newRoot = document.createElement(\"div\");\n newRoot.classList.add(\"notationBlockRoot\");\n if (config.cssClasses?.root) {\n newRoot.className += \" \" + config.cssClasses.root;\n }\n this.newRoot = newRoot;\n\n // Build HTML structure\n let html = \"\";\n\n // Add source code section if showSource is true\n if (this.showSource) {\n const sourceLines = this.source.split(\"\\n\");\n const sourceClass = config.cssClasses?.sourceContainer || \"\";\n const captionClass = config.cssClasses?.sourceCaption || \"\";\n const codeClass = config.cssClasses?.sourceCode || \"\";\n\n html += `\n <figure class=\"notation-source-block ${sourceClass}\">\n <div class=\"notation-source-header\">\n <figcaption class=\"notation-caption ${captionClass}\">${this.caption}</figcaption>\n <div class=\"notation-source-actions\">\n <button class=\"notation-btn notation-copy-btn\" id=\"copyBtn_${this.id}\" title=\"Copy to clipboard\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\">\n <path d=\"M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V2zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H6zM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1H2z\"/>\n </svg>\n <span class=\"notation-btn-text\">Copy</span>\n </button>\n <button class=\"notation-btn notation-edit-btn\" id=\"editBtn_${this.id}\" title=\"Edit notation\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\">\n <path d=\"M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z\"/>\n </svg>\n <span class=\"notation-btn-text\">Edit</span>\n </button>\n </div>\n </div>\n <div class=\"notation-source\" id=\"notationSource_${this.id}\">\n <pre class=\"notation-source-pre\">\n <code class=\"${codeClass}\" id=\"sourceCode_${this.id}\">${sourceLines.map((x) => `<span>${x}</span>`).join(\"\\n\")}</code>\n </pre>\n <textarea class=\"notation-edit-textarea\" id=\"editTextarea_${this.id}\" style=\"display: none;\"></textarea>\n </div>\n <div class=\"notation-edit-actions\" id=\"editActions_${this.id}\" style=\"display: none;\">\n <button class=\"notation-btn notation-apply-btn\" id=\"applyBtn_${this.id}\">Apply</button>\n <button class=\"notation-btn notation-cancel-btn\" id=\"cancelBtn_${this.id}\">Cancel</button>\n </div>\n </figure>`;\n }\n\n // Add output section\n const outputLabelClass = config.cssClasses?.outputLabel || \"\";\n const outputClass = config.cssClasses?.outputContainer || \"\";\n\n html += `\n <div class=\"notation-output\">\n <span class=\"notation-output-label ${outputLabelClass}\"><strong>Output:</strong></span>\n <div id=\"notationViewer_${this.id}\" class=\"notation-view ${outputClass}\">\n </div>\n </div>`;\n\n newRoot.innerHTML = html;\n parent.insertBefore(newRoot, container);\n parent.removeChild(container);\n\n const notationViewerBlock = newRoot.querySelector(\".notation-view\") as HTMLDivElement;\n this.notationView = config.createViewer(notationViewerBlock);\n\n // Set up event handlers\n if (this.showSource) {\n this.sourceCodeElement = newRoot.querySelector(`#sourceCode_${this.id}`);\n this.editTextarea = newRoot.querySelector(`#editTextarea_${this.id}`);\n\n // Copy button\n const copyBtn = newRoot.querySelector(`#copyBtn_${this.id}`);\n if (copyBtn) {\n copyBtn.addEventListener(\"click\", () => this.copyToClipboard());\n }\n\n // Edit button\n const editBtn = newRoot.querySelector(`#editBtn_${this.id}`);\n if (editBtn) {\n editBtn.addEventListener(\"click\", () => this.toggleEditMode());\n }\n\n // Apply button\n const applyBtn = newRoot.querySelector(`#applyBtn_${this.id}`);\n if (applyBtn) {\n applyBtn.addEventListener(\"click\", () => this.applyEdit());\n }\n\n // Cancel button\n const cancelBtn = newRoot.querySelector(`#cancelBtn_${this.id}`);\n if (cancelBtn) {\n cancelBtn.addEventListener(\"click\", () => this.cancelEdit());\n }\n }\n\n this.updatePreview();\n console.log(\"Done Rendering... Adjusting height\");\n }\n\n updatePreview(): void {\n const fullContents = this.source;\n // Clear previous render to avoid appending multiple times\n this.notationView.tableElement.innerHTML = \"\";\n\n const [notation, beatLayout, errors, timings] = load(fullContents, { log: true });\n\n if (errors.length > 0) {\n console.log(\"Errors: \", errors);\n } else {\n console.log(\"Rendering notation...\");\n this.notationView.renderNotation(notation, beatLayout);\n }\n\n const msg = `Document parsed (${Math.trunc(timings.parseTime * 100) / 100} ms) and built (${\n Math.trunc(timings.buildTime * 100) / 100\n } ms)`;\n console.log(msg);\n }\n\n get captionId(): string {\n return \"notationCaption_\" + this.id;\n }\n\n async copyToClipboard(): Promise<void> {\n try {\n await navigator.clipboard.writeText(this.source);\n const copyBtn = this.newRoot.querySelector(`#copyBtn_${this.id}`);\n if (copyBtn) {\n const btnText = copyBtn.querySelector(\".notation-btn-text\");\n const originalText = btnText?.textContent;\n if (btnText) {\n btnText.textContent = \"Copied!\";\n setTimeout(() => {\n if (btnText) btnText.textContent = originalText || \"Copy\";\n }, 2000);\n }\n }\n } catch (err) {\n console.error(\"Failed to copy to clipboard:\", err);\n alert(\"Failed to copy to clipboard\");\n }\n }\n\n toggleEditMode(): void {\n this.isEditing = !this.isEditing;\n\n if (this.isEditing) {\n this.enterEditMode();\n } else {\n this.exitEditMode();\n }\n }\n\n enterEditMode(): void {\n if (!this.editTextarea || !this.sourceCodeElement) return;\n\n // Populate textarea with current source\n this.editTextarea.value = this.source;\n\n // Hide source code, show textarea\n if (this.sourceCodeElement.parentElement) {\n this.sourceCodeElement.parentElement.style.display = \"none\";\n }\n this.editTextarea.style.display = \"block\";\n\n // Auto-resize textarea to fit content\n this.editTextarea.style.height = \"auto\";\n this.editTextarea.style.height = this.editTextarea.scrollHeight + \"px\";\n\n // Show edit actions\n const editActions = this.newRoot.querySelector(`#editActions_${this.id}`) as HTMLElement;\n if (editActions) {\n editActions.style.display = \"flex\";\n }\n\n // Update edit button text\n const editBtn = this.newRoot.querySelector(`#editBtn_${this.id}`);\n const btnText = editBtn?.querySelector(\".notation-btn-text\");\n if (btnText) {\n btnText.textContent = \"Editing...\";\n }\n\n this.editTextarea.focus();\n }\n\n exitEditMode(): void {\n if (!this.editTextarea || !this.sourceCodeElement) return;\n\n // Hide textarea, show source code\n this.editTextarea.style.display = \"none\";\n if (this.sourceCodeElement.parentElement) {\n this.sourceCodeElement.parentElement.style.display = \"block\";\n }\n\n // Hide edit actions\n const editActions = this.newRoot.querySelector(`#editActions_${this.id}`) as HTMLElement;\n if (editActions) {\n editActions.style.display = \"none\";\n }\n\n // Update edit button text\n const editBtn = this.newRoot.querySelector(`#editBtn_${this.id}`);\n const btnText = editBtn?.querySelector(\".notation-btn-text\");\n if (btnText) {\n btnText.textContent = \"Edit\";\n }\n }\n\n applyEdit(): void {\n if (!this.editTextarea) return;\n\n // Update source\n this.source = this.editTextarea.value;\n\n // Update source code display\n if (this.sourceCodeElement) {\n const sourceLines = this.source.split(\"\\n\");\n this.sourceCodeElement.innerHTML = sourceLines.map((x) => `<span>${x}</span>`).join(\"\\n\");\n }\n\n // Re-render notation\n this.updatePreview();\n\n // Exit edit mode\n this.isEditing = false;\n this.exitEditMode();\n }\n\n cancelEdit(): void {\n // Simply exit edit mode without applying changes\n this.isEditing = false;\n this.exitEditMode();\n }\n}\n"]}
@@ -0,0 +1,41 @@
1
+ import { CellModel, NotebookCssClasses } from "../types/notebook";
2
+ export interface NotebookCellConfig {
3
+ cssClasses?: NotebookCssClasses;
4
+ markdownParser?: (content: string) => string;
5
+ showDeleteButton?: boolean;
6
+ showMoveButtons?: boolean;
7
+ onStartEdit?: (cellId: string) => void;
8
+ onApplyEdit?: (cellId: string, newSource: string) => void;
9
+ onCancelEdit?: (cellId: string) => void;
10
+ onDelete?: (cellId: string) => void;
11
+ onMoveUp?: (cellId: string) => void;
12
+ onMoveDown?: (cellId: string) => void;
13
+ onToggleExpanded?: (cellId: string) => void;
14
+ createChildCell?: (cell: CellModel, parent: HTMLElement) => NotebookCell;
15
+ }
16
+ export default class NotebookCell {
17
+ readonly element: HTMLDivElement;
18
+ readonly cell: CellModel;
19
+ readonly config: NotebookCellConfig;
20
+ private childCells;
21
+ private editTextarea;
22
+ constructor(cell: CellModel, config?: NotebookCellConfig);
23
+ private buildRootClassName;
24
+ private render;
25
+ private renderHeader;
26
+ private createBadge;
27
+ private createControls;
28
+ private renderError;
29
+ private renderContent;
30
+ private renderPreviewMode;
31
+ private renderEditMode;
32
+ private renderChildren;
33
+ private handleStartEdit;
34
+ private handleApplyEdit;
35
+ private handleCancelEdit;
36
+ private handleDelete;
37
+ private handleToggleExpanded;
38
+ getEditSource(): string;
39
+ update(newCell: CellModel): void;
40
+ destroy(): void;
41
+ }