Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: the rendererer poc #137

Closed
wants to merge 11 commits into from
Closed

feat: the rendererer poc #137

wants to merge 11 commits into from

Conversation

phanshiyu
Copy link
Contributor

@phanshiyu phanshiyu commented May 10, 2024

why

  • adding svg rendering support requires user to deal with 2 different interfaces
  • user should not need to handle logic to differentiate between not just OA document versions, but also render methods
  • the frame connector interface is complicated, this a good chance for us to improve

what

a component that takes in a document, and renders it

poc of a Renderer with a simple interface that handles both svg and embedded renderer

user potentially does not need to deal with frame actions or whatever

const Viewer: React.FunctionComponent<ViewerProps> = ({ document }): React.ReactElement => {
  const [selectedTemplate, setSelectedTemplate] = useState<string>("");
  const [rendererResults, setRendererResults] = useState<ConnectedResults>();

  return (
    <div>
      {/* render tabs */}
      {rendererResults?.type === "EMBEDDED_RENDERER" && (
        <ul>
          {rendererResults.templates.map((template) => (
            <li
              key={template.id}
              className={`tab ${selectedTemplate === template.id ? "selected" : ""}`}
              onClick={() => {
                setSelectedTemplate(template.id);
                rendererResults.selectTemplate({
                  id: template.id,
                });
              }}
            >
              <a href="#">{template.label}</a>
            </li>
          ))}
        </ul>
      )}
      {/* print button */}
      <button
        onClick={() => {
          rendererResults?.print();
        }}
      >
        Print
      </button>
      <TheRenderer
        document={document.document}
        onConnected={(results) => {
          console.log(results);
          setRendererResults(results);
          if (results.type === "EMBEDDED_RENDERER") {

            setSelectedTemplate(results.selectedTemplateId);
          }
        }}
        onError={({ type, ...rest }) => {
          console.error(type);
          console.error(rest);
        }}
        onObfuscation={({ updatedDocument, field }) => {
          console.log(updatedDocument);
          console.log(field);
        }}
        loadingComponent={<>loading...</>}
      />;
    </div>
  );
};
  • support v4 documents
  • return typed objects for error
  • loading component
  • obfuscation out of the box
  • sandbox props
  • getData under the hood
  • jsdocs
  • migration guide

feat: support v4

feat: allowing printing svg

fix: proper renderer error types

fix: only reset frame connector when needed, feat: loading component

refactor: reorg
@phanshiyu phanshiyu force-pushed the feat/the-renderer-poc branch from 0272e80 to 2a2684a Compare May 12, 2024 04:27
@phanshiyu phanshiyu closed this May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant