zyratlo commented on code in PR #5256:
URL: https://github.com/apache/texera/pull/5256#discussion_r3424038211


##########
notebook-migration-service/src/main/resources/custom.js:
##########
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// Use Jupyter's event system to ensure the notebook is fully loaded
+require(["base/js/events"], function (events) {
+  events.on("kernel_ready.Kernel", function () {
+
+    // Attach click event listener to cells
+    $("#notebook-container").on("click", ".cell", function (event) {
+      const cell = $(this);
+      const index = $(".cell").index(cell);
+      const cellContent = cell.find(".input_area").text();
+
+      // Get the UUID from the cell's metadata, or use "N/A" if it doesn't 
exist
+      const cellUUID = Jupyter.notebook.get_cell(index).metadata.uuid || 'N/A';
+
+      // Send a message to the parent window (Texera app)
+      window.parent.postMessage(
+        { action: "cellClicked", cellIndex: index, cellContent: cellContent, 
cellUUID: cellUUID },
+        "http://localhost:4200";
+      );

Review Comment:
   I made it config-driven in 288c3cc5b. I introduced a `TEXERA_ORIGIN` env 
var, `custom.js` now reads a `__TEXERA_ORIGIN__` placeholder that a new 
`start-texera-jupyter.sh` substitutes at container startup, covering both the 
`postMessage` target and the inbound origin check.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to