0.1.115 • Published 7 months ago

@scalar/api-reference-editor v0.1.115

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

API Reference Editor

Scalar API references with an integrated editor. The editor can be used in two ways:

Internal State Management

You (optionally) provide an initial value and the editor will manage any changes internally.

<!doctype html>
<html>
  <head>
    <title>API Reference Editor</title>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1" />
    <!-- TODO: Update import script -->
    <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference-editor"></script>
  </head>
  <body>
    <div id="scalar-api-reference" />
    <script>
      import { mountApiReferenceEditable } from '@scalar/api-reference-editor'

      mountApiReferenceEditable('#scalar-api-reference')
    </script>
  </body>
</html>

External State Management

To have additional control over when the references are updated you can provide a configuration.spec.content value and then handle the custom event that is emitted from the Editor component. A handler can be passed directly to the mountApiReferenceEditable function or you can attach an event listener for scalar-update to the mounted div.

If you wish to have external UI that updates the spec then updateSpecValue can be used to force update the content.

<!doctype html>
<html>
  <head>
    <title>API Reference Editor</title>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1" />
    <!-- TODO: Update import script -->
    <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference-editor"></script>
  </head>
  <body>
    <div id="scalar-api-reference" />
    <script>
      import { mountApiReferenceEditable } from '@scalar/api-reference-editor'

      const externalState = {
        value: ''
      }

      const { updateSpecValue} = mountApiReferenceEditable(
        '#scalar-api-reference',
        { spec: {content: ''}},
        (v: string) => {
          console.log('The value is updated!')
          updateSpecValue(v) // Updates the rendered spec
          externalState.value = v
        }
      )
    </script>
  </body>
</html>
0.1.114

7 months ago

0.1.115

7 months ago

0.1.113

8 months ago

0.1.110

8 months ago

0.1.112

8 months ago

0.1.111

8 months ago

0.1.109

8 months ago

0.1.108

8 months ago

0.1.107

8 months ago

0.1.106

8 months ago

0.1.98

8 months ago

0.1.99

8 months ago

0.1.103

8 months ago

0.1.102

8 months ago

0.1.105

8 months ago

0.1.104

8 months ago

0.1.101

8 months ago

0.1.100

8 months ago

0.1.97

8 months ago

0.1.96

8 months ago

0.1.90

8 months ago

0.1.91

8 months ago

0.1.92

8 months ago

0.1.93

8 months ago

0.1.94

8 months ago

0.1.95

8 months ago

0.1.85

8 months ago

0.1.86

8 months ago

0.1.87

8 months ago

0.1.88

8 months ago

0.1.89

8 months ago

0.1.80

9 months ago

0.1.81

9 months ago

0.1.82

9 months ago

0.1.83

9 months ago

0.1.84

9 months ago

0.1.79

9 months ago

0.1.75

9 months ago

0.1.76

9 months ago

0.1.77

9 months ago

0.1.78

9 months ago

0.1.71

9 months ago

0.1.72

9 months ago

0.1.73

9 months ago

0.1.70

9 months ago

0.1.69

9 months ago

0.1.68

9 months ago

0.1.66

10 months ago

0.1.65

10 months ago

0.1.64

10 months ago

0.1.63

10 months ago

0.1.62

10 months ago

0.1.61

10 months ago

0.1.60

10 months ago

0.1.59

10 months ago

0.1.58

10 months ago

0.1.57

10 months ago

0.1.56

10 months ago

0.1.55

10 months ago

0.1.54

10 months ago

0.1.53

10 months ago

0.1.52

10 months ago

0.1.51

10 months ago

0.1.50

10 months ago

0.1.49

10 months ago

0.1.48

11 months ago

0.1.47

11 months ago

0.1.46

11 months ago

0.1.45

11 months ago

0.1.44

11 months ago

0.1.43

11 months ago

0.1.42

11 months ago

0.1.41

11 months ago

0.1.40

11 months ago

0.1.39

11 months ago

0.1.38

11 months ago

0.1.37

11 months ago

0.1.36

11 months ago

0.1.35

11 months ago

0.1.34

11 months ago

0.1.33

11 months ago

0.1.32

11 months ago

0.1.31

11 months ago

0.1.30

11 months ago

0.1.29

11 months ago

0.1.27

11 months ago

0.1.26

11 months ago

0.1.25

11 months ago

0.1.24

11 months ago

0.1.23

11 months ago

0.1.22

11 months ago

0.1.21

11 months ago

0.1.20

11 months ago

0.1.19

11 months ago

0.1.18

11 months ago

0.1.17

11 months ago

0.1.16

11 months ago

0.1.15

11 months ago

0.1.14

11 months ago

0.1.12

11 months ago

0.1.11

11 months ago

0.1.10

12 months ago

0.1.9

12 months ago

0.1.8

12 months ago

0.1.7

12 months ago

0.1.6

12 months ago

0.1.5

12 months ago

0.1.4

12 months ago

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago