搜尋套件、儲存庫與 APP 分類

套件詳情v0.7.14+5.65.18

codemirror

一個包裝 CodeMirror 文本編輯器的 Dart 封裝。

Web
近 30 天下載
1330
喜歡數
20
Pub 分數
120

安裝套件

flutter pub add codemirror

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Dart 包裝器,用於 CodeMirror 文本編輯器,讓 Flutter Web 應用程式能夠實現豐富的程式碼編輯功能。它提供語法強調、行號顯示和可自訂主題,直接在瀏覽器中利用強大的 CodeMirror 庫。此套件非常適合建立互動式程式碼編輯器、類似 IDE 的功能,或任何需要支援特定語言語法的進階文字編輯應用程式。對於僅限 Web 的 Flutter 項目,整合無縫,確保熟悉且高效能的編輯體驗。

適用情境

  • 基於網路的程式碼編輯器
  • 互動式編碼教程
  • 類似IDE的Web應用
  • 即時程式碼協作
  • 語法高亮輸入欄位

主要特色

  • 語法強調
  • 行號
  • 可自訂主題
  • 基於瀏覽器的渲染
  • 透過 CodeMirror 外掛程式可擴充

適合對象

  • Flutter web 開發人員
  • 教育平台
  • 程式碼分享工具
  • 開發者工具
  • 基於網路的整合開發環境

使用建議

  • 僅限 Web 的平台支援
  • 需要 JavaScript 互操作
  • 僅限瀏覽器環境
  • 依賴外部 CodeMirror 庫
  • 可能增加封包大小

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

codemirror.dart

Build Status pub package

What is it?

A Dart wrapper around the CodeMirror text editor. From codemirror.net:

CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code, and comes with a number of language modes and addons that implement more advanced editing functionality.

Note: This is NOT a Flutter package, it is a Dart package for writing web applications like DartPad.

An example

final options = <String, String>{
  'mode': 'javascript',
  'theme': 'monokai'
};

final editor = CodeMirror.fromElement(
    document.querySelector('#textContainer')!, options: options);
editor.doc.setValue('foo.bar(1, 2, 3);');

See also our example/ directory.

How do I use it?

In your main html file, link to the style sheet:

<link href="packages/codemirror/codemirror.css" rel="stylesheet">

reference the CodeMirror JavaScript code:

<script src="packages/codemirror/codemirror.js"></script>

and, in your Dart code, import the library:

import 'package:codemirror/codemirror.dart';

What about modes? Addons?

This Dart package ships with several language modes built in. CodeMirror itself supports over 100 modes; the modes built into the Dart package include the usual suspects for web development - css, html, dart and javascript as well as a few others. In order to add additional modes, you'll need to reference the mode file from your html entry point. So,

<script src="packages/codemirror/mode/lua.js"></script>

will bring in support for Lua.

Similarly with addons, we've included a few common ones, and have made the others available to import on a case-by-case basis. In order to use the active-line addon, import:

<script src="packages/codemirror/addon/selection/active-line.js"></script>

Be aware that many addons need additional configuration in order to enable then. This is generally done by passing values into the options of the CodeMirror constructor.

Some addons are exposed through the main Dart interface. Some are exposed via side-car Dart libraries available in the main package, and some have yet to be exposed. Pull requests welcome :)

Themes

By importing the codemirror.css file:

<link href="packages/codemirror/codemirror.css" rel="stylesheet">

You get access to all the CodeMirror themes. If you only want a few, or don't want to pay the network roundtrip cost to load all the themes, you can import only the ones you're interested in:

<link href="packages/codemirror/theme/monokai.css" rel="stylesheet">
<link href="packages/codemirror/theme/zenburn.css" rel="stylesheet">

Disclaimer

This is not an official Google product.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。