Giter Club home page Giter Club logo

copenhagen's Introduction

๐Ÿ‡ฉ๐Ÿ‡ฐ Copenhagen Editor

Copenhagen is a free, lightweight and hackable open source code editor for the web. It's responsible for powering the code-editing experience on Autocode, and it's written entirely in vanilla JavaScript with only highlight.js and feather icons bundled as dependencies.

Documentation is available at copenhagen.autocode.com. You can also play around with your own installation right away by forking this repository in Autocode:

Copenhagen Demo

Getting Started

To get started with Copenhagen, add copenhagen.0-1-4.min.css and copenhagen.0-1-4.min.js to your web project. You can find them in this repository. Then import them to your webpage by adding the following lines in the <head> tag of your webpage:

<!-- Copenhagen Editor -->
<link rel="stylesheet" href="./compiled/copenhagen.0-1-4.min.css">
<script src="./compiled/copenhagen.0-1-4.min.js"></script>

You can then instantiate a new Editor adding the following JavaScript within a <script> tag:

// Use DOMContentLoaded or whatever instantiation code you'd like,
// just make sure the page is ready...
window.addEventListener('DOMContentLoaded', function () {

  // instantiated CPHEditor instance with config
  var editor = new Copenhagen.Editor({language: 'javascript'});

  // open, but do not auto-focus the editor
  editor.open(this.selector('.some-selector'), false);

  // set a value
  editor.setValue('var message = `hello world`;');

});

Alternatively, you can automatically convert all elements matching a specific selector. This will automatically pass in config values via data-* attributes on the HTML tag.

<div class="editor" data-language="html" data-maxrows="20">
  // some code
</div>
window.addEventListener('DOMContentLoaded', function () {
  var editors = Copenhagen.initSelectorAll('.editor');
});

Documentation

Documentation is available at copenhagen.autocode.com/docs.html.

Hacking the Editor, Contributing

Hacking the editor and making updates is simple. We recommend you install the Autocode command line tools to get started.

Autocode CLI, stdlib/lib on Github

Once installed, you can run your own local instance of the Autocode HTTP gateway using;

$ lib http

And then visit http://localhost:3434/dev/raw/ or http://localhost:3434/dev/min/ to play with the raw or minified compiled version of the editor. You can change the editor code via the src/ directory in this repository.

Compiling Copenhagen

You can only compile the editor when running locally, this is not available via the Autocode web interface because live web services run a read-only filesystem.

To compile changes to a single script / css file, simply run:

$ lib .compile --filename script.js --min t --write t
$ lib .compile --filename style.css --min t --write t

You can remove the --min t flag if you want to compile the non-minified versions.

Development and license

The development of Copenhagen is funded by commercial interests and is owned by Polybit Inc. DBA Autocode but is fully open source and MIT licensed. We do not profit off of the development of Copenhagen directly; proceeds from our commercial offering help fund its development.

Updates and who to follow

You can follow Autocode team updates on Twitter at @AutocodeHQ. The primary author of Copenhagen is @keithwhor (Keith Horwood) with the support of @Hacubu (Jacob Lee). Special thanks to @threesided (Scott Gamble) and @YusufMusleh for hundreds of hours of testing in total, and thanks to our users and customers for plenty of feedback. Enjoy Copenhagen, we sure have! ๐Ÿ˜Ž

copenhagen's People

Contributors

keithwhor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.