Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Collaborative Text Editor Powered by Firebase

License

NotificationsYou must be signed in to change notification settings

codehs/firepad

 
 

Repository files navigation

Firepad is an open-source, collaborative code and text editor. It isdesigned to be embedded inside larger web applications.

Join ourFirebase Google Group to askquestions, request features, or share your Firepad apps with the community.

Status

Status: Frozen

This repository is no longer under active development. No new features will be added and issues are not actively triaged. Pull Requests which fix bugs are welcome and will be reviewed on a best-effort basis.

If you maintain a fork of this repository that you believe is healthier than the official version, we may consider recommending your fork. Please open a Pull Request if you believe that is the case.

Table of Contents

Getting Started With Firebase

Firepad requiresFirebase in order to sync and store data. Firebaseis a suite of integrated products designed to help you develop your app, grow your user base, andearn money. You cansign up here for a free account.

Live Demo

Visitfirepad.io to see a live demo of Firepad in rich text mode, or theexamples page to see it setup for collaborative code editing.

a screenshot of demo.firepad.io including a picture of two cats and a discussion about fonts

Downloading Firepad

Firepad usesFirebase as a backend, so it requires no server-sidecode. It can be added to any web app by including a few JavaScript files:

<head><!-- Firebase --><scriptsrc="https://www.gstatic.com/firebasejs/7.13.2/firebase-app.js"></script><scriptsrc="https://www.gstatic.com/firebasejs/7.13.2/firebase-auth.js"></script><scriptsrc="https://www.gstatic.com/firebasejs/7.13.2/firebase-database.js"></script><!-- CodeMirror --><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.17.0/codemirror.js"></script><linkrel="stylesheet"href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.17.0/codemirror.css"/><!-- Firepad --><linkrel="stylesheet"href="https://firepad.io/releases/v1.5.10/firepad.css"/><scriptsrc="https://firepad.io/releases/v1.5.10/firepad.min.js"></script></head>

Then, you need to initialize the Firebase SDK and Firepad:

<bodyonload="init()"><divid="firepad"></div><script>functioninit(){// Initialize the Firebase SDK.firebase.initializeApp({apiKey:'<API_KEY>',databaseURL:'https://<DATABASE_NAME>.firebaseio.com'});// Get Firebase Database reference.varfirepadRef=firebase.database().ref();// Create CodeMirror (with lineWrapping on).varcodeMirror=CodeMirror(document.getElementById('firepad'),{lineWrapping:true});// Create Firepad (with rich text toolbar and shortcuts enabled).varfirepad=Firepad.fromCodeMirror(firepadRef,codeMirror,{richTextShortcuts:true,richTextToolbar:true,defaultText:'Hello, World!'});}</script></body>

Documentation

Firepad supports rich text editing withCodeMirror and code editing viaAce. Check out the detailed setup instructions atfirepad.io/docs.

Examples

You can find some Firepad exampleshere.

Contributing

If you'd like to contribute to Firepad, please first read through ourcontributionguidelines. Local setup instructions are availablehere.

Database Structure

How is the data structured in Firebase?

  • <document id>/ - A unique hash generated when pushing a new item to Firebase.
    • users/
      • <user id>/ - A unique hash that identifies each user.
        • cursor - The current location of the user's cursor.
        • color - The color of the user's cursor.
    • history/ - The sequence of revisions that are automatically made as the document is edited.
      • <revision id>/ - A unique id that ranges from 'A0' onwards.
        • a - The user id that made the revision.
        • o/ - Array of operations (eg TextOperation objects) that represent document changes.
        • t - Timestamp in milliseconds determined by the Firebase servers.
    • checkpoint/ - Snapshot automatically created every 100 revisions.
      • a - The user id that triggered the checkpoint.
      • id - The latest revision at the time the checkpoint was taken.
      • o/ - A representation of the document state at that time that includes styling and plaintext.

Repo Structure

Here are some highlights of the directory structure and notable source files:

  • dist/ - output directory for all files generated by grunt (firepad.js,firepad.min.js,firepad.css,firepad.eot).
  • examples/ - examples of embedding Firepad.
  • font/ - icon font used for rich text toolbar.
  • lib/
    • firepad.js - Entry point for Firepad.
    • text-operation.js,client.js - Heart of the Operation Transformation implementation. Based onot.js but extended to allow arbitraryattributes on text (for representing rich-text).
    • annotation-list.js - A data model for representing annotations on text (i.e. spans of text with a particularset of attributes).
    • rich-text-codemirror.js - UsesAnnotationList to track annotations on the text and maintain the appropriateset of markers on a CodeMirror instance.
    • firebase-adapter.js - Handles integration with Firebase (appending operations, triggering retries,presence, etc.).
  • test/ - Jasmine tests for Firepad (many of these were borrowed from ot.js).

About

Collaborative Text Editor Powered by Firebase

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript89.4%
  • CSS6.7%
  • CoffeeScript2.1%
  • Shell1.4%
  • HTML0.4%

[8]ページ先頭

©2009-2025 Movatter.jp