8000 The software keyboard is abnormal when the vue-mathlive is embedded by the iframe · Issue #89 · arnog/vue-mathlive · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

The software keyboard is abnormal when the vue-mathlive is embedded by the iframe #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jlsunlight opened this issue Aug 24, 2023 · 4 comments

Comments

@jlsunlight
Copy link

When vue-mathlive is embedded by iframe, the keyboard does not display

@arnog
Copy link
Owner
arnog commented Aug 24, 2023

Can you provide a project demonstrating the issue?

@jlsunlight
Copy link
Author
<!-- math-live.html -->
<!DOCTYPE html>
<html lang="en-US">
  <head>
    <link rel="stylesheet" href="style.css" />
    <title>MathLive with by iframe</title>
  </head>
  <style>
    body {
      font-family: sans-serif;
      color: #444;
      background-color: #f9f9f9;
    }
    main {
      max-width: 820px;
      margin: auto;
    }
    .mathfield {
      border: 1px solid #ddd;
      padding: 5px;
      margin: 10px 0 10px 0;
      border-radius: 5px;
      background-color: #fff;
    }
  </style>

  <body>
    <script type="module">
      import Vue from "https://cdn.jsdelivr.net/npm/vue/dist/vue.esm.browser.js";
      import * as MathLive from "https://unpkg.com/mathlive/dist/mathlive.mjs";
      import MathfieldComponent from "https://unpkg.com/mathlive/dist/vue-mathlive.mjs";
      Vue.config.devtools = true;

      Vue.use(MathfieldComponent, MathLive);
      // The default tag for mathfields is <mathlive-mathfield>
      // A custom tag can be defined using:
      // ```Vue.component("custom-tag", Mathfield);```

      new Vue({
        el: "main",
        data: {
          formula: "",
          keystroke: "",
        },
        methods: {
          sayIt: (event) => {
            // this.$refs.mathfield.executeCommand(["speak", "all"]);
          },
          setIt: (event) => {
            // this.formula = "x=-b\\pm \\frac {\\sqrt{b^2-4ac}}{2a}";
          },
          ping: () => {
            console.log("ping");
          },
          displayKeystroke: (keystroke, _ev) => {
            this.keystroke = keystroke;
            return true;
          },
          asSpokenText: function () {
            return this.$refs.mathfield
              ? this.$refs.mathfield.getValue("spoken")
              : "";
          },
        },
        mounted,
      });

      async function mounted() {
        this.$mathlive.renderMathInElement(this.$refs["static-math"]);
      }
    </script>
    <main>
      <h2>MathLive with by iframe</h2>
      <mathlive-mathfield
        id="mf"
        ref="mathfield"
        :options="{smartFence:false, virtualKeyboardMode:'onfocus'}"
        @focus="ping"
        :on-keystroke="displayKeystroke"
        v-model="formula"
        >f(x)=</mathlive-mathfield
      >

      <div ref="static-math">\[x^2 = x*x\]</div>
    </main>
  </body>
</html>
<!-- index.html -->
<!DOCTYPE html>
<html lang="en-US">
  <head>
    <!-- <title>MathLive with by iframe</title> -->
  </head>

  <body>
    <div id="app">
      <iframe src="./math-live.html" frameborder="0"></iframe>
    </div>
  </body>
</html>

@arnog
Copy link
Owner
arnog commented Sep 3, 2023

For the keyboard to be displayed in the parent document you must load the MathLive module in the parent document.

@jlsunlight
Copy link
Author
jlsunlight commented Sep 3, 2023
<!-- index.html -->
<!DOCTYPE html>
<html lang="en-US">
  <head>
    <!-- <title>MathLive with by iframe</title> -->
  </head>

  <body>
    <div id="app">
      <iframe src="./math-live.html" frameborder="0"></iframe>
    </div>
  </body>
  <script type="module" src="">
    import Vue from "https://cdn.jsdelivr.net/npm/vue/dist/vue.esm.browser.js";
    import * as MathLive from "https://unpkg.com/mathlive/dist/mathlive.mjs";
    import MathfieldComponent from "https://unpkg.com/mathlive/dist/vue-mathlive.mjs";
    Vue.config.devtools = true;

    Vue.use(MathfieldComponent, MathLive);
  </script>
</html>

I load the MathLive module in the parent document but the keyboard didn't displayed in the parent document,Can you provide a example or project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0