GithubHelp home page GithubHelp logo

Comments (11)

youdz avatar youdz commented on May 3, 2024 1

Hi @amellnik, this is a good catch. A quick investigation reveals that when hitting back, Prism is run on the <code> element before the example is interpolated in.

Our code highlight component was initially meant for our static website demos, and listening to changes to its inner text requires quite the refactor. I will raise this to the team and we will see if we can fix it, how and when.

In the meantime, we do have a wrapper component that we have been using for more complex demos: example.ts
It is slightly more dynamic, you don't have to worry about escaping brackets since you use interpolation (just like you've been doing in your demo app), and is slightly easier to use. That said, it still doesn't listen to example code changes, but that's as easy as using a setter on the input:

private _code: string;
public get code() {
    return this._code;
}
@Input("clrCode") public set code(raw: string) {
    this._code = raw;
    this.codeHighlight.redraw();
}

I hope this helps.

from clarity.

CrisLi avatar CrisLi commented on May 3, 2024 1

@youdz I found there is a problem in the demo code (maybe a defect for CodeHighlight component). When the @Input("clrCode") public code: string; changed in the parent component, the code highlight block is still the old value. The component variable code is changed, but the rendered DOM is not changed.

from clarity.

mathisscott avatar mathisscott commented on May 3, 2024 1

Code highlight component is targeted for removal in 0.12.

from clarity.

gnomeontherun avatar gnomeontherun commented on May 3, 2024 1

We will when we officially deprecate it in the next release.

from clarity.

youdz avatar youdz commented on May 3, 2024

@CrisLi: Thanks for the bug report, we will look at it and probably fix it as part of a more general refactor of the code highlight component, because at the moment it really doesn't support anything dynamic.

from clarity.

amellnik avatar amellnik commented on May 3, 2024

One further thought -- once it can handle dynamic content it would be nice to have an easy way to enable code highlighting on a text or textarea input, specifying the language and possibly even the refresh rate (ie, wait for 1 second without changes to re-color).

from clarity.

dgrahn avatar dgrahn commented on May 3, 2024

The link to the example.ts file is broken.

from clarity.

youdz avatar youdz commented on May 3, 2024

It got moved here: https://github.com/vmware/clarity/blob/master/src/app/_utils/code-example.ts

from clarity.

amellnik avatar amellnik commented on May 3, 2024

Would it make sense to add a note to the top of the code highlight documentation saying that it will be removed in the future?

from clarity.

gnomeontherun avatar gnomeontherun commented on May 3, 2024

Deprecation notice provided.

from clarity.

github-actions avatar github-actions commented on May 3, 2024

Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.

from clarity.

Related Issues (20)

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.