Giter VIP home page Giter VIP logo

ui-ace's Introduction

AngularUI - The companion suite for AngularJS


Build Status

Usage

Requirements

  • AngularJS v1.0.0+ is currently required.
  • jQuery / Plugins (depends on directive). Check specific directive dependencies for more information

Installation

The repository comes with the modules pre-built and compressed into the build/ directory.

angular.module('myApp', ['ui']);

The modules can be found in the Directives and Filters folders. Check out the readme file associated with each module for specific module usage information.

Development

You do not need to build the project to use it - see above - but if you are working on it then this is what you need to know.

Requirements

  1. Install Node.js and NPM (should come with)

  2. Install local dependencies:

$ npm install
  1. Install global dependencies grunt, coffee-script, and testacular:
$ npm install -g testacular coffee-script grunt

Build Files & Run Tests

Before you commit, always run grunt to build and test everything once.

$ grunt

Test & Develop

The modules come with unit tests that should be run on any changes and certainly before commiting changes to the project. The unit tests should also provide further insight into the usage of the modules.

First, start the testacular server:

$ grunt server

Then, open your browser to http://localhost:8080 and run the watch command to re-run tests on every save:

$ grunt watch

Publishing

For core team: if you wish to publish a new version follow these steps:

  1. Bump the version number inside package.json
  2. Build and test
  3. Commit the updated package.json and build/ folder on their own commit
  4. Tag the commit: git tag v[maj].[min].[patch]
  5. Push the tag: git push [angular-ui] master --tags

ui-ace's People

Contributors

0x-r4bbit avatar benshell avatar choxi avatar ciel avatar douglasduteil avatar ebuildy avatar erikpena avatar marshall007 avatar mlabieniec avatar nickradford avatar peterdavehello avatar powerkiki avatar proloser avatar rebornix avatar ricochet1k avatar rotoshine avatar slopjong avatar wesleycho avatar zeitiger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ui-ace's Issues

Automatically scrolling cursor into view after selection change this will be disabled in the next version set editor.$blockScrolling = Infinity to disable this message

After upgraded to version 1.1.9. The console started be polluted by this message:

Automatically scrolling cursor into view after selection change this will be disabled in the next version set editor.$blockScrolling = Infinity to disable this message

I have a lot of ui-ace editors, most of them don't have any onLoad. Can you take them away? Thanks.

Changing value on the $scope not updating the editor?

Hi,

I was a bit surprised to find out that when I update the $scope variable, the editor does not update.
Do I need to call some update method? Does that mean I need to save the editor from the onLoad event? Or is there something I can inject into my controller?

I'm wondering why this is not built-in.

Thanks

"$digest already in progress" error occurs when using onChange attribute with ui-ace 0.2.0

After upgrading to ui-ace 0.2.0, I get the following error when ui-ace calls my onChange function:

Error: [$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.3.8/$rootScope/inprog?p0=%24digest
    at REGEX_STRING_REGEXP (https://localtest.evergage.com:8443/ui/bower_components/angular/angular.js:63:12)
    at beginPhase (https://localtest.evergage.com:8443/ui/bower_components/angular/angular.js:14737:15)
    at Scope.$get.Scope.$apply (https://localtest.evergage.com:8443/ui/bower_components/angular/angular.js:14481:11)
    at link.executeUserCallback (https://localtest.evergage.com:8443/ui/bower_components/angular-ui-ace/ui-ace.js:199:19)
    at Array.link.listenerFactory.onChange (https://localtest.evergage.com:8443/ui/bower_components/angular-ui-ace/ui-ace.js:237:15)
    at r._signal (https://localtest.evergage.com:8443/ui/bower_components/ace-builds/src-min-noconflict/ace.js:1:48711)
    at onChange (https://localtest.evergage.com:8443/ui/bower_components/ace-builds/src-min-noconflict/ace.js:1:149291)
    at r._signal (https://localtest.evergage.com:8443/ui/bower_components/ace-builds/src-min-noconflict/ace.js:1:48711)
    at removeInLine (https://localtest.evergage.com:8443/ui/bower_components/ace-builds/src-min-noconflict/ace.js:1:120868)
    at remove (https://localtest.evergage.com:8443/ui/bower_components/ace-builds/src-min-noconflict/ace.js:1:120408)

I am using Angular 1.3.8 and Ace 1.1.7.

Here's what my HTML looks like:

<div ng-model="formData.cssContent"
        ui-ace="{ useWrapMode: true, mode: 'css', onLoad: aceLoaded, onChange: contentChanged }"         
        ng-readonly="!contentEditable">
</div>

$applyAsync() is only in Angular v1.3 and above.

I assume your intention was to continue supporting those of us lingering on the 1.1.x and 1.2.x branches, but unfortunately moving from $apply() to $applyAsync() has failed in that endeavor. I haven't read the conversation for why that move needed to be made, but the newer function is undefined on $scope in earlier branches and this causes erratic, breaking behavior.

Adding a custom ace/mode crashes with "define not defined"

angular-ui-ace works great, I got ACE embedded in my Angular app. Next problem is I'm trying to load a custom mode. In my $scope.aceLoaded callback, I am able to set the modePath as follows:

ace.config.set("modePath", "customModes");
...
session.setMode('ace/mode/tester');

So far so good, it loads the mode-tester.js mode from customModes. However, mode-test.js promply crashes with:

Uncaught ReferenceError: define is not defined 

At the first line which looks like this (see the Wiki):

define('ace/mode/tester', function(require, exports, module) {

So clearly, things like "define" and "require" aren't getting set up. Not sure if this is a requirejs thing, although it seems as thus far I haven't needed to use requirejs with Angular.

Any ideas?

Update version available via Bower

The version available via bower doesn't match the updated one in github. In particular I needed the code from #26 , so I had to track the github commit rather than the normal bower install.

OnLoad option does not get evaluated to function

Based on the OnLoad example in the ReadMe, the function name is not $eval-ed to the OnLoad function defined on a ng-controller's scope.

I suspect that this will also occur with onChange as well

Set validity of ngModel

Hey,

what would be the best way to set the validity of ngModel, based on the value of getAnnotations?

I can access the getAnntations values by doing the following in my controller

$scope.aceLoaded = function(editor) {
  editor.getSession().on('changeAnnotation', function() {
    var annot = editor.getSession().getAnnotations();
  });
};

Within the uiAcedirective it would be possible to set the validity of the model by calling ngModel.$setValidity('annotations', isValid)

Whats your opinion about implementing this within the uiAce directive?

Bests, Mark

Specify font family or families and font size?

I didn't see an easy way to do this. I tried the obvious, with no luck:

  $scope.uiAceConfig =
    useWrapMode : true
    showGutter: true
    theme: 'twilight'
    mode: 'html'
    fontFamily: 'Inconsolata'
    fontSize: '16px'
<div ui-ace="uiAceConfig" ng-model="content.html"></div>

Anyone find a way to do this? Thanks!

readonly doesn't appear to work

When we try to use <div ui-ace readonly="true"></div>, the editor doesn't become read-only. I think it may have something to do with the fact that the browser renders readonly="true" as just readonly, and if you only include the readonly attribute itself in the Plunker example, it doesn't work either. The ="true" part is mandatory but you can't get that to show up in the source (at least not in Chrome stable).

cc: @jmartin4563

Form elements?

Does Ace work with other elements besides <div>? I've got something like this:

<div ui-ace style="height: 200px;"></div>

...which shows the ace editor in the div, as expected. But if I just change it to this:

<textarea ui-ace class="form-control" style="height: 200px;"></textarea>

I can't even load the page -- Chromium tab will just hang, and eventually crash.

EDIT: sorry, I copied the sample code in incorrectly -- fixed now.

Access to ace.config

is it possible to forward options or get access to the ace.config object? in our case we want to modify the basePath option to load themes and mode files from a specific folder

ace.config.set("basePath", "/path/to/src");

Syntax error message doesn't disappear

In some cases the syntax error doesn't disappear anymore. As the screenshot shows I can edit the json in ace which is rendered as a tree on the right, which perfectly works.

If no other people are experiencing this, it has to be a local issue, which I need to investigate further.

2014-04-16-211059_803x128_scrot

editor.insert doesn't appear to trigger model change

I'm trying to create some actions to insert pre-defined text into the editor, but it doesn't appear to cause the model to change.

template:

in controller:

editor.insert("text to insert");

this is not causing the updateDefinition() method to be called.

Different height for multiple ace editors in one page

I use the recommended way to set the height of the editor by adding this global CSS:

.ace_editor {
    height: 200px;
}

Now what if I have two ace editors, but I want to set different height for them. How can I set height separately for them?

Thanks,
Elgs

Dynamic mode using model variable

Hi there!

It's possible to set editor mode dynamically, using model variable?

I already tried use them as parameter on the onLoad function but it appears not be supported.

Thanks!

ui-ace editor options set after, rather than before, onLoad callback function is called

In our app, we have a page with 3 ui-ace editors on the same page - one in html mode, one in css mode, and one in javascript mode. We use the same onLoad callback function for all three, since we want to set most of the same ACE options. But we also want to do a couple things specific to which editor is being configured. In order to determine, in the onLoad function, which of the three editors was being configured, we checked if the editor's mode was html, css, or javascript.

We recently upgraded Angular from 1.2 to 1.3, and ui-ace from 1.1.2 to 1.2.1. After these upgrades, the code described above stopped working, because the onLoad function was being called before, rather than after, the ui-ace options specified in the html had been applied.

Run the below plunk with the browser console open and watch the logging. Notice, that in onchange, the mode specified via ui-ace options in the html has not yet been set on the ACE editor (it's still set to the default mode, "text"), but after a $timeout, the mode has been set to "css".

http://plnkr.co/edit/QGr1j8jjRCVsaTVDveEA?p=preview

The question is, does it make more sense to call the onLoad callback before or after setting the ui-ace options on the ACE editor. I'm thinking setting them before might be more intuitive. What do you think?

Whatever is decided, I think it would be good to document the order in the README.

Opt tabSize missing

The option tabSize is missing in the directive so when we define it, it's not taken in account by ace.

  if (angular.isDefined(opts.tabSize)) {
    session.setTabSize(opts.tabSize);
  }

No license in javascript

The javascript file does not contain any comment as to the source of the code or the license it is under. This makes it difficult for end users to see the license. Could this be added to the source files?

Add marker _session.addMarker

It is possible to create marker for example.
I have error with Range constructor
TypeError: Illegal constructor
Example :

$scope.aceLoaded = function(_editor){
var _session = _editor.getSession();
_session.addMarker(new Range(1, 0, 10, 0), "ace_active-line", "fullLine");
};

Contribution guidance

Hi there - my team uses angular-ui-ace and would love to help with some outstanding issues:

  • Existing issues #65, #43, and #29
  • Helping however possible with the release cycle time - from getting a release tagged to having it available via bower
  • Triage/label/review issues/PRs

I know I can just do PRs on the first three, and we've already dealt with things like #43 via bower overrides, but what about the second? I noticed there is a bower branch, tags, a download link to the tag on http://angular-ui.github.io/ui-ace/. Just looking for some contribution guidance here. Let me know where you could use the most help.

$digest already in progress

I sadly can't reproduce this error very easily but there are cases where I was making multiple editors on a page with ng-models (in an ng-repeat directive) and I was getting $digest already in progress from the onchange handler. There is already a line in here checking for scope.$$phase but I had to also check the rootscope using scope.$root.$$phase. This fixed my problem and appeared to work fine. I have no idea what the ramifications of this are as I'm pretty new to this stuff but I'd hoped that someone here could tell me.

onLoad callback not being called

I am following the Readme, and I can't get the onLoad callback to work. During troubleshoooting, it appears that

    if (angular.isFunction(opts.onLoad)) 

in ui-ace.js is evaluating false. No code placed in this block executes.

My controller is taken straight from the readme.

var myModule = angular.module('joes_ide', ['ui.ace']);

myModule.controller('MyController', [ '$scope', function($scope) {

  $scope.aceLoaded = function(_editor){
    // Editor part
    var _session = _editor.getSession();
    var _renderer = _editor.renderer;

    // Options
    _editor.setReadOnly(true);
    _session.setUndoManager(new ace.UndoManager());
    _renderer.setShowGutter(false);

    // Events
  //  _editor.on("changeSession", function(){ ... });
   // _session.on("change", function(){ ... });
  };

}]);

Likewise, my view-

<div ui-ace="{
  useWrapMode : true,
  showGutter: false,
  theme:'twilight',
  mode: 'xml',
  onLoad: aceLoaded,
  onChange: aceChanged
}"></div>

JSON Stringify on Arrays and Objects

Is there some specific reason why the ui-ace throws an exception when we are dealing with array or object types? At the first glance it seems perfectly safe to just stringify those types. Am I missing something?

Just wanted to hear your opinion about stringifying those before I submitted a PR.

Support fontSize

I propose to support also this option

    if (angular.isDefined(opts.fontsize)) {
      acee.setFontSize(opts.fontsize);
    }

That we could use as aceOption :

$scope.aceOption = {
mode: 'xml',
theme: $scope.theme.toLowerCase(),
fontsize: '18px',

ace.js in bower.json

I'm working on learning AngularJS and associated workflow using the Yeoman generator-angular to scaffold the basic seed project. I'm evaluating a couple embeddable editors and installed ui-ace via Bower:

bower install angular-ui-ace -S

This properly installs everything to bower_components and adds ui-ace.js as a dependency in bower.json:

{
  ...
  "angular-ui-ace": "~0.1.1"
}

Which in turn adds the script to index.html on grunt:

<script src="bower_components/angular-ui-ace/ui-ace.js"></script>

The issue is ace.js (which is required) is not added as a dependency on install:

<script type="text/javascript" src="bower_components/ace-builds/src-min-noconflict/ace.js"></script>

Does anyone know the proper syntax to add it as a dependency in bower.json so it is included in my build?

memory leaks

Ace will leak when the directive is removed by angular.

I had the editor in a tab-content controlled by ng-switch, the results were bad.

My solution for now is just using my own tab implementation that does not delete and recreate the elements like ng-switch does.

Broken on 1.3.2

ui.ace was working on angular-1.3.0-beta.9 but is broken on 1.3.2 with this error:

TypeError: Cannot read property '$formatters' of null
    at link (http://localhost:3041/vendor/angular-ui-ace/ui-ace.js:171:18)
    at invokeLinkFn (http://localhost:3041/vendor/angular/angular.js:8125:9)
    at nodeLinkFn (http://localhost:3041/vendor/angular/angular.js:7637:11)
    at compositeLinkFn (http://localhost:3041/vendor/angular/angular.js:6993:13)
    at nodeLinkFn (http://localhost:3041/vendor/angular/angular.js:7632:24)
    at compositeLinkFn (http://localhost:3041/vendor/angular/angular.js:6993:13)
    at compositeLinkFn (http://localhost:3041/vendor/angular/angular.js:6996:13)
    at publicLinkFn (http://localhost:3041/vendor/angular/angular.js:6872:30)
    at compile (http://localhost:3041/vendor/angular-ui-router/release/angular-ui-router.js:2805:9)
    at invokeLinkFn (http://localhost:3041/vendor/angular/angular.js:8125:9) <div ui-ace="{
          useWrapMode : true,
          showGutter: false,
          theme:'twilight',
          mode: 'sql',
          onLoad: aceLoaded,
          onChange: aceChanged
        }" class=" ace_editor ace-tm"> 

Theme and mode 404 when using minified/bundled js and workerPath

I'm using requirejs, as as such, all JS gets concatenated into a single file. I'm setting workerPath to the correct folder containing Ace, but theme and mode don't seem to get picked up. Even specifying paths for both have no effect.
screenshot 2015-04-23 00 32 28

Any thoughts on how to correctly get theme and mode working with a requirejs / concatenated / uglified / set up?

Relevant config:

    $scope.uiAceConfig =
      theme: 'chrome'
      mode: 'html'
      onLoad: $scope.aceLoaded
      workerPath: '/public/lib/ace-builds/src-min-noconflict'

Thanks!

inside of aceLoaded getValue() returns null

when calling aceLoaded getValue() or getLine(0) returns null. So the value is not available in this moment.

$scope.aceLoaded = function(_editor) {
    var _session = _editor.getSession();
    console.log(_session.getValue());

Upgrade dependency to latest version of Ace editor?

version 1.1.1 has some significant improvements over 1.0.0

Using Ace 1.1.1 in my ui-ace setup seems to result in the editor initialising but now displaying (what's with that?).

Has anyone looked into where the incompatibility lies? How hard would a fix be?


Update: setting .ace_editor { position: absolute; } seems to fix the no display issue. Are there any other reasons to be hesitant about updating ui-ace's dependency?

Update Ace

Seems like ace has stopped tagging releases in ajaxorg/ace-builds (last one was 8 months ago), despite lots of new updates being released.

Would it be possible to update ui-ace's dependencies to just use the latest from ace-builds?

onLoad and directives

The onLoad option works great if the parent element is a controller, however if it's a directive it's never called:

http://plnkr.co/edit/CvPSaccYVKZfoesJC7o4?

The problem is it just hasn't binded yet. I hacked around it using this:

    setTimeout(function() {
        opts = angular.extend({}, options, scope.$eval(attrs.uiAce));
        if (angular.isFunction(opts.onLoad)) {
            opts.onLoad(acee);
        }
    }, 0);

However this clearly is slightly hacky (not to mention I had to edit ui-ace, which I'd rather not do). A $watch would probably work as well (and be more appropriate here).

(Thanks for this directive, by the way -- it's been an awesome help.)

How do you initialize the editor when directives get compiled after the controller?

I haven't been able to get the example editor initialization to work because it looks like the directive is compiled after the controller is initialized. Here's an example:

In the html:

<div ng-controller="MyController">
  <div ui-ace scope-instance="foo"></div>
</div>

In the controller:

myAppModule.controller('MyController', [ '$scope', function($scope) {

  // this is undefined because
  // the controller is initialized 
  // before the directive is compiled
  var _editor = $scope.foo; 
}]);

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.