본문으로 건너뛰기
cccskills
무료GitHub에 공개

create-file-viewer

Create a custom file viewer for the Datagrok file share browser

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md3.6 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Create File Viewer

Create a custom file viewer that is used by the Datagrok file share browser to display files with specific extensions.

Usage

/create-file-viewer [extensions] [package-path]

Instructions

When this skill is invoked, help the user create a custom file viewer for one or more file extensions. Use the /ui skill for building the UI if necessary.

Step 1: Create the viewer function

Add a function to package.ts (or a separate file imported by it) with the correct annotations. The function must:

  • Accept a single file input
  • Return a view
  • Have the fileViewer tag plus a fileViewer-<ext> tag for each supported extension
//name: myFileViewer
//tags: fileViewer, fileViewer-xyz, fileViewer-abc
//input: file file
//output: view v
export function myFileViewer(file: DG.FileInfo) {
  let view = DG.View.create();

  // Read file content and render it
  file.readAsString().then((content) => {
    let host = ui.div([]);
    // Process and display content
    host.innerText = content;
    view.append(host);
  });

  return view;
}

Step 2: Handle file content

Choose the appropriate method to read file content:

  • file.readAsString() - for text-based files (returns Promise<string>)
  • file.readAsBytes() - for binary files (returns Promise<Uint8Array>)

Example for binary files:

//tags: fileViewer
//input: file file
//output: view v
//meta.fileViewer: mol, sdf, cif
export function structureViewer(file: DG.FileInfo) {
  let view = DG.View.create();
  let host = ui.div([], 'd4-ngl-viewer');

  file
    .readAsBytes()
    .then(bytes => {
      // Process binary content
      let blob = new Blob([bytes]);
      // Render blob...
    });

  view.append(host);
  return view;
}

Key points

  • The function runs when a user clicks on a file with a matching extension in the file share browser
  • The view is displayed in the file preview panel
  • Return the view synchronously; load file content asynchronously inside it
  • meta.fileViewer can take multiple extensions

For extensions that are efficiently DataFrames

  • Return a DG.TableView directly — do not wrap a grid in a custom DG.View
  • Transfer all source metadata to tags (table-level and column-level) so it survives round-trips through the platform
// Good — file viewer for a single-table format
static async previewFoo(file: DG.FileInfo): Promise<DG.View> {
  const bytes = await file.readAsBytes();
  const data = await parseFoo(bytes);
  const df = toDataFrame(data);
  const view = DG.TableView.create(df, false);
  view.name = file.name;
  return view;
}
  • Set df.setTag('source.format', '...') to record where the data came from
  • Preserve column-level metadata (description, format, categories) as tags
  • Use a namespace prefix for format-specific tags (e.g., minitab.version, prism.sheetId)
  • Use the standard description tag for column descriptions

For extensions that contain multiple dataframes

  • Use custom DG.View
  • Show global file metadata on top
  • 'Open all' big button on the ribbon
  • Tab control with pane per dataframe

Behavior

  1. Ask the user which file extension(s) they want to support if not specified
  2. Determine whether the file is text-based or binary to choose readAsString vs readAsBytes
  3. Create the viewer function with correct tags for all specified extensions
  4. Add rendering logic appropriate for the file type

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Add support for a new curve data format in the Curves package converter system

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

datagrok-ai/public742026년 10월 20일 업데이트

Create info panels that appear in the context panel based on semantic types

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

datagrok-ai/public742026년 10월 20일 업데이트

Add a new single-objective optimization algorithm to the sci-comp library. Use when the user asks to implement a new optimizer (e.g. gradient descent, BFGS, simulated annealing, differential evolution).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

datagrok-ai/public742026년 10월 20일 업데이트

Add unit tests to a Datagrok package

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

datagrok-ai/public742026년 10월 20일 업데이트

Answer a "how do I …" question about the platform with a Gherkin scenario on @datagrok-libraries/bdd that is filmed into a how-to video (grok-bdd guide), so the answer is demonstrated, sent as a video plus numbered steps, and kept as a regression test; the same scenarios, filmed in help mode, are the GIFs of the help pages

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

datagrok-ai/public742026년 10월 20일 업데이트

Translate hand-written Playwright specs (or any existing UI tests) into Gherkin features on @datagrok-libraries/bdd, then prove the features test what they claim by backward-matching them against the originals with independent reviewers, and fix the gaps in the core, the library and the features

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

datagrok-ai/public742026년 10월 20일 업데이트

datagrok-ai의 스킬 모두 보기

이 스킬의 문제 신고