Giter Club home page Giter Club logo

Comments (2)

donl avatar donl commented on August 22, 2024

I believe this contains how it was done previously: https://github.com/pengx17/json-schema/blob/master/main.jsx

The current version of Monico Editor appears to have removed the quickOpen however.

Let me know if you have any success.

from monaco-yaml.

remcohaszing avatar remcohaszing commented on August 22, 2024

Sorry, if it's the wrong place to ask

Technically yes, but I think breadcrumbs are a nice way to show the features provided by monaco-yaml. You can see how I implemented breadcrumbs in https://github.com/remcohaszing/monaco-yaml/pull/94/files

It basically comes down to:

import { editor, languages, Position, Range } from 'monaco-editor';
import { CancellationToken } from 'monaco-editor/esm/vs/base/common/cancellation';
import { getDocumentSymbols } from 'monaco-editor/esm/vs/editor/contrib/documentSymbols/documentSymbols';

function* iterateSymbols(
  symbols: languages.DocumentSymbol[],
  position: Position,
): Iterable<languages.DocumentSymbol> {
  for (const symbol of symbols) {
    if (Range.containsPosition(symbol.range, position)) {
      yield symbol;
      yield* iterateSymbols(symbol.children, position);
    }
  }
}

const ed = editor.create(document.getElementById('editor'), {
  value: '',
  language: 'yaml',
});

ed.onDidChangeCursorPosition(async (event) => {
  const symbols = await getDocumentSymbols(ed.getModel(), false, CancellationToken.None);
  // Do whatever you want with the symbols here. :)
});

This uses some undocumented, untyped monaco-editor APIs, so it may break with newer releases of monaco-editor. Providing the document symbols based on YAML content is a feature of monaco-yaml and will continue to work.

from monaco-yaml.

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.