@advanced-rest-client/raw-payload-editor

中文文档
3.0.7发布于 2021/10/01Apache-2.0ESM + CJS近 30 天下载 3240

A raw payload input editor based on CodeMirror

原始使用文档
文档目录9 节
  1. Breaking Changes in v3
  2. API components
  3. Usage
  4. Installation
  5. In an html file
  6. In a LitElement
  7. development
  8. Running the demo locally
  9. Running the tests

DEPRECATED

This component is deprecated. The code base has been moved to body-editor module.


An element with CodeMirror editor to allow the user to enter HTTP message body.

This component is no longer developed. Please, do not use it.

Breaking Changes in v3

  1. Upgrade

The element now uses LitElement library instead of Polymer. This means that all attributes are lowercase without - characters. For example, previously the lineSeparator property was reflected to line-separator attribute. Now it is lineseparator attribute.

  1. Tab handling

CodeMirror traps focus in the editor area. This is not accessible way of handling user input. Because of that this element overrides default tab key behavior and removes focus from the element.

  1. Required imports

This version uses latest and final specs for web components. This means the component works as a ES module. Because of that CodeMirror and any related library has to be included into the document before inserting this element to the DOM. CodeMirror 6 possibly will be working with ES imports but this is not set in stone at the moment.

Below is the default set of scripts to be added to the document.

<script src="node_modules/codemirror/lib/codemirror.js"></script>
<script src="node_modules/codemirror/addon/mode/loadmode.js"></script>
<script src="node_modules/codemirror/mode/meta.js"></script>
<!--Default set of parsers -->
<script src="node_modules/codemirror/mode/javascript/javascript.js"></script>
<script src="node_modules/codemirror/mode/xml/xml.js"></script>
<script src="node_modules/codemirror/mode/htmlmixed/htmlmixed.js"></script>

If you are using JSON linter

<script src="node_modules/jsonlint/lib/jsonlint.js"></script>
<script src="node_modules/codemirror/addon/lint/lint.js"></script>
<script src="node_modules/codemirror/addon/lint/json-lint.js"></script>
<link rel="stylesheet" href="node_modules/codemirror/addon/lint/lint.css" />

Finally, if your application will use modes that aren't included in the document, you should set import URI. This will be used to resolve modes dependencies.

<script>
CodeMirror.modeURL = 'node_modules/codemirror/mode/%N/%N.js';
</script>

API components

This components is a part of API components ecosystem

Usage

Installation

npm install --save @advanced-rest-client/raw-payload-editor

In an html file

<html>
  <head>
    <script type="module">
      import '@advanced-rest-client/raw-payload-editor/raw-payload-editor.js';
    </script>
  </head>
  <body>
    <raw-payload-editor contenttype="application/json"></raw-payload-editor>
    <script>
    {
      document.querySelector('raw-payload-editor').onvalue = (e) => {
        console.log(e.target.value);
      }
    }
    </script>
  </body>
</html>

In a LitElement

import { LitElement, html } from 'lit-element';
import '@advanced-rest-client/code-mirror/code-mirror.js';

class SampleElement extends PolymerElement {
  render() {
    return html`
    <code-mirror contenttype="application/json" @value-changed="${this._valueHandler}"></code-mirror>
    `;
  }

  _valueHandler(e) {
    this.value = e.detail.value;
  }
}
customElements.define('sample-element', SampleElement);

development

git clone https://github.com/advanced-rest-client/raw-payload-editor
cd raw-payload-editor
npm install

Running the demo locally

npm start

Running the tests

npm test

版本与发布记录

@advanced-rest-client/raw-payload-editor 共发布 11 个版本,首次发布于 2019/02/23;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.0.7latest2021/10/015 年前
3.0.62019/11/216 年前
3.0.52019/10/177 年前
3.0.42019/08/247 年前
3.0.32019/08/207 年前
3.0.22019/08/207 年前

关于 @advanced-rest-client/raw-payload-editor 的常见问题

@advanced-rest-client/raw-payload-editor 是什么?

A raw payload input editor based on CodeMirror

如何安装 @advanced-rest-client/raw-payload-editor?

在项目目录运行 npm install @advanced-rest-client/raw-payload-editor,或使用 pnpm add / yarn add / bun add。

@advanced-rest-client/raw-payload-editor 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/advanced-rest-client__raw-payload-editor 是否存在。

@advanced-rest-client/raw-payload-editor 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@advanced-rest-client/raw-payload-editor 可以商用吗?

@advanced-rest-client/raw-payload-editor 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@advanced-rest-client/raw-payload-editor 的下载量有多少?

根据 npm 官方下载统计,@advanced-rest-client/raw-payload-editor 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,240 次,日均约 108 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@advanced-rest-client/raw-payload-editor 还在维护吗?

最新版本 3.0.7 发布于 2021/10/01(5 年前);至今共发布 11 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/02/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。