+
95
-

grapesjs文本添加超链接如何改成下拉选择?

grapesjs文本添加超链接如何改成下拉选择?

800_auto

默认是文本输入框,太繁琐了。

网友回复

+
15
-

这样

800_auto

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/grapes.0.21.1.css">
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/grapes.0.21.1.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/grapesjs-preset-webpage.1.0.2.js"></script>
  <style>
    body, html {
      height: 100%;
      margin: 0;
    }
    #gjs {
      border: 3px solid #444;
    }
  </style>
</head>
<body>
  <div id="gjs" style="height:100%;"></div>

  <script>
    document.addEventListener('DOMContentLoaded', function () {
      const editor = grapesjs.init({
        container: '#gjs',
        fromElement: true,
        height: '100%',
        width: 'auto',
        plugins: ['gjs-preset-webpage'],
        pluginsOpts: {
          'gjs-preset-webpage': {}
        }
      });

      // Initial content
      editor.setComponents(`
        <div>
          <p id="selectable-link">Click here to select a link<...

点击查看剩余70%

我知道答案,我要回答