Skip to content

[FR] Add compute engine plugin to easily compute formulas too #40

@simon-schober

Description

@simon-schober

It would be really cool to be able to compute formulas using this Logseq plugin too and cortex-js/compute-engine already does this really well in the math field element itself by just adding an extra script. Here's a basic HTML example that adds this to a MathField element

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script src="https://unpkg.com/mathlive"></script>
  <script type="module">
    import "https://esm.run/@cortex-js/compute-engine"
  </script>
  <math-field id="mf" virtual-keyboard-mode="on"></math-field>
</body>

</html>
<!-- MathLive provides a <math-field> web component -->

I tried to implement this into the plugin, but there seems to be issues with a simple

import "https://esm.run/@cortex-js/compute-engine"
Uncaught Error: Dynamic require of "https://esm.run/@cortex-js/compute-engine" is not supported
    at index.js:1:402
    at index.js:155:1305
    at index.js:163:3967

as I don't think the configuration or Logseq itself or the build command allows this.

adding it using html in index.html also didn't work

  <script src="https://unpkg.com/mathlive"></script>
  <script src="https://cdn.jsdelivr.net/npm/@cortex-js/compute-engine/compute-engine.min.umd.js"></script>
  <script type="module" src="./dist/index.js"></script>
index.html:15 
GET https://cdn.jsdelivr.net/npm/@cortex-js/compute-engine/compute-engine.min.umd.js net::ERR_ABORTED 404 (Not Found)
index.html:1 Refused to execute script from 'https://cdn.jsdelivr.net/npm/@cortex-js/compute-engine/compute-engine.min.umd.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.

I don't have too much experience with any of the tech stack here, so I couldn't do it myself, but maybe this helps

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions