每当存储文本中的信息发生更改时,如何存储文件版本控制?

问题描述

参考旧问题如何在重复使用文档并且仅修改某些信息时自动使用 word 导入现有文本。 目前,我找到了带有 JS 和 HTML 的 word 任务窗格加载项解决方案。 下面是我的 JS 函数代码

/* global document,Office,Word */

Office.onReady(info => {
  if (info.host === Office.HostType.Word) {
    // Determine if the user's version of Office supports all the Office.js APIs that are used in the tutorial.
    if (!Office.context.requirements.isSetSupported('WordApi','1.3')) {
      console.log('Sorry. The tutorial add-in uses Word.js APIs that are not available in your version of Office.');
    }

    // Assign event handlers and other initialization logic.
    document.getElementById("ka1-se").onclick = insertParagraph;
    document.getElementById("apply-style").onclick = applyStyle;

    document.getElementById("sideload-msg").style.display = "none";
    document.getElementById("app-body").style.display = "flex";
  }
});



function insertParagraph() {
  Word.run(function (context) {

    var docBody = context.document.body;
    docBody.insertParagraph("ANNEX III – FINANCIAL AND CONTRACTUAL RULES","Start");

    return context.sync();
  })
    .catch(function (error) {
      console.log("Error: " + error);
      if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
      }
    });
}

function applyStyle() {
  Word.run(function (context) {

    var firstParagraph = context.document.body.paragraphs.getFirst();
    firstParagraph.styleBuiltIn = Word.Style.intenseReference;

    return context.sync();
  })
    .catch(function (error) {
      console.log("Error: " + error);
      if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
      }
    });
}

对于 html:

跳到内容

<!DOCTYPE html>
<html>

<head>
  <Meta charset="UTF-8" />
  <Meta http-equiv="X-UA-Compatible" content="IE=Edge" />
  <Meta name="viewport" content="width=device-width,initial-scale=1">

  <!-- Office JavaScript API -->
  <script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script>

  <!-- For more information on Office UI Fabric,visit https://developer.microsoft.com/fabric. -->
  <link rel="stylesheet"
    href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/9.6.1/css/fabric.min.css" />

  <!-- Template styles -->
  <link href="taskpane.css" rel="stylesheet" type="text/css" />
</head>

<body class="ms-font-m ms-welcome ms-Fabric">
  <header class="ms-welcome__header ms-bgColor-neutralLighter">
  </header>
  <section id="sideload-msg" class="ms-welcome__main">
  </section>
  <main id="app-body" class="ms-welcome__main" style="display: none;">
    <button class="ms-Button" id="ka1-se">KA1 SE</button><br/><br/>
    <button class="ms-Button" id="apply-style">Apply Style</button><br/><br/>
  </main>
</body>

</html>

现在,我的想法是,最后我将它们变成多个复选框,用于存储大量文本作为可重用数据,并且它们将在提交按钮上填充文档。 问题 1:有没有办法进行文件版本控制?我会需要它,因为很可能文本会发生变化,并且以某种方式在已经存在的内容之上自动保存最后一个版本会很好。问题 2 听起来很愚蠢:如何保存大块文本在复选框后面而不仅仅是一个简单的段落?不知道我说得够不够清楚。 欢迎提出任何建议。

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)