@acrolinx/app-sdk 中文文档教程

发布于 3年前 浏览 16 项目主页 更新于 3年前

Acrolinx App SDK

用于在 Acrolinx 边栏内运行的应用程序的 SDK。

Installation

npm install @acrolinx/app-sdk

Example Code

TypeScript/ES6

import {RequiredCommands, RequiredEvents, DEVELOPMENT_APP_SIGNATURE, initApi} from '@acrolinx/app-sdk';

// Initialize the Acrolinx App API
const api = initApi({
  appSignature: DEVELOPMENT_APP_SIGNATURE,
  title: 'App Title',
  button: {
    text: 'Extract Text',
    tooltip: 'Extract text from the document'
  },
  requiredCommands: [RequiredCommands.openWindow],
  requiredEvents: [RequiredEvents.textExtracted],
});

// Listen to events
api.events.textExtracted.addEventListener(textExtractedEvent => {
  console.log('textExtractedEvent', textExtractedEvent.text, textExtractedEvent.languageId);
});

// Execute commands
api.commands.openWindow('https://www.acrolinx.com');

Plain old JavaScript

如果您更喜欢在没有 npm 和捆绑器的情况下使用普通的旧 JavaScript 进行编码, 您可以使用缩小浏览器包。 在这种情况下,您可以在全局命名空间 acrolinxAppSdk 中找到 SDK。

<script src="https://unpkg.com/@acrolinx/app-sdk/dist/acrolinx-app-sdk.min.js"></script>
<script>
  var api = acrolinxAppSdk.initApi({....
</script>

请查看相应的现场演示。 请注意,当此应用程序未加载到 Acrolinx 边栏内时,它不会做太多事情。

App Icon

应用程序图标需要按照约定命名为“acrolinx-app-icon.svg”,并且必须放在应用程序 html 文件旁边(示例) .

Demo Projects

  • Extract Text (demonstrates text extraction)
  • Word Cloud (demonstrates text extraction and displays the results in a react word cloud component)
  • Select Ranges (demonstrates text extraction, select ranges and replace ranges)

References

Authentication

序列图

License

版权所有 2019 年至今 Acrolinx GmbH

根据 Apache 许可证 2.0 版(“许可证”)获得许可; 除非遵守许可证,否则您不得使用此文件。 您可以在以下位置获得许可证的副本:

http://www.apache.org/licenses/LICENSE-2.0

除非适用法律要求或书面同意,软件 根据许可证分发是在“按原样”的基础上分发的, 没有任何明示或暗示的保证或条件。 请参阅许可证以获取特定语言的管理权限和 许可证下的限制。

如需更多信息,请访问:https://www.acrolinx.com

Acrolinx App SDK

SDK for apps running inside of the Acrolinx Sidebar.

Installation

npm install @acrolinx/app-sdk

Example Code

TypeScript/ES6

import {RequiredCommands, RequiredEvents, DEVELOPMENT_APP_SIGNATURE, initApi} from '@acrolinx/app-sdk';

// Initialize the Acrolinx App API
const api = initApi({
  appSignature: DEVELOPMENT_APP_SIGNATURE,
  title: 'App Title',
  button: {
    text: 'Extract Text',
    tooltip: 'Extract text from the document'
  },
  requiredCommands: [RequiredCommands.openWindow],
  requiredEvents: [RequiredEvents.textExtracted],
});

// Listen to events
api.events.textExtracted.addEventListener(textExtractedEvent => {
  console.log('textExtractedEvent', textExtractedEvent.text, textExtractedEvent.languageId);
});

// Execute commands
api.commands.openWindow('https://www.acrolinx.com');

Plain old JavaScript

If you prefer to code in plain old JavaScript without npm and without a bundler, you can use the minified browser bundle. In this case you can find the SDK in the global namespace acrolinxAppSdk.

<script src="https://unpkg.com/@acrolinx/app-sdk/dist/acrolinx-app-sdk.min.js"></script>
<script>
  var api = acrolinxAppSdk.initApi({....
</script>

Please have a look at the corresponding live demo. Please note that this app does not do much when not loaded inside of an Acrolinx Sidebar.

App Icon

The app icon needs to be named by convention "acrolinx-app-icon.svg" and must put next to the app html file (example).

Demo Projects

  • Extract Text (demonstrates text extraction)
  • Word Cloud (demonstrates text extraction and displays the results in a react word cloud component)
  • Select Ranges (demonstrates text extraction, select ranges and replace ranges)

References

Authentication

Sequence Diagram

License

Copyright 2019-present Acrolinx GmbH

Licensed 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.

For more information visit: https://www.acrolinx.com

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文