当前位置: 首页 > news >正文

html网页制作模板图片seo基本概念

html网页制作模板图片,seo基本概念,经营一个网站要怎么做,室内设计平面图库Monaco 是微软开源的一个编辑器,VSCode 也是基于 Monaco 进行开发的。如果在 React 中如何使用 Monaco,本文将介绍如何在 React 中引入 Monaco。 安装 React 依赖 yarn add react-app-rewired --dev yarn add monaco-editor-webpack-plugin --dev yarn…

Monaco 是微软开源的一个编辑器,VSCode 也是基于 Monaco 进行开发的。如果在 React 中如何使用 Monaco,本文将介绍如何在 React 中引入 Monaco。

安装 React 依赖

yarn add react-app-rewired --dev
yarn add monaco-editor-webpack-plugin --dev
yarn add monaco-editor
yarn add react-monaco-editor

创建Webpack 配置文件并添加插件

在项目的根目录下创建 config-overrides.js

const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');module.exports = function override(config, env) {config.plugins.push(new MonacoWebpackPlugin({languages: ['json']}));return config;
}

引入 Monaco 组件

核心函数 handleEditorDidMount,行选中时,在行尾添加一句话,通过事件监听函数 onDidChangeCursorSelection 和 Decoration 进行实现

import logo from './logo.svg';
import './App.css';
import MonacoEditor from 'react-monaco-editor';
import { useRef, useState,useEffect }  from 'react';function App() {const editorRef = useRef(null);const monacoRef = useRef(null);const decorationsRef = useRef([]);const handleEditorDidMount = (editor, monaco) => {editorRef.current = editor;monacoRef.current = monaco;// Add an event listener for cursor position changeseditor.onDidChangeCursorSelection(() => {const selection = editor.getSelection();// if (selection.isEmpty()) {//   // Remove decorations if selection is empty//   editor.deltaDecorations(decorationsRef.current, []);//   return;// }const lineNumber = selection.positionLineNumber;const lineContent = editor.getModel().getLineContent(lineNumber);if (lineContent !== "") {// Add decoration if the line starts with 'var'const newDecorations = editor.deltaDecorations(decorationsRef.current, [{range: new monaco.Range(lineNumber, 1, lineNumber, 1),options: {isWholeLine: true,afterContentClassName: 'myAfterContentDecoration'}}]);decorationsRef.current = newDecorations;} else {// Remove decorations if the line does not start with 'var'editor.deltaDecorations(decorationsRef.current, []);}});};useEffect(() => {// Define custom styles for the decorationsconst style = document.createElement('style');style.innerHTML = `.myAfterContentDecoration::after {content: ' // 备注';color: green;font-weight: bold;}`;document.head.appendChild(style);}, []);return (<div style={{'margin':'100px auto', 'width': '800px'}}><MonacoEditorwidth="800"height="600"language="javascript"theme="vs-dark"value={""}options={""}editorDidMount={handleEditorDidMount}/></div>);
}export default App;

在这里插入图片描述

总结

Monaco 功能非常强大,API 也比较复杂,后面后陆续看看它的 API 如何使用。

http://www.hkea.cn/news/70216/

相关文章:

  • 在线网站设计百度收录查询方法
  • 最新体育新闻足球百度seo收费
  • 手机网站做跳转好吗个人在百度上发广告怎么发
  • 民宿网站的建设最近热搜新闻事件
  • 企业网站建设的核心是企业推广视频
  • 设计素材网站蜂产品推广文章
  • wordpress站点描述seo哪个软件好
  • 澳门服务器做网站需要备案吗百度ai人工智能平台
  • 做化验的在哪个网站里投简历河南网站关键词优化
  • 百度网址大全网站大全网络整合营销方案ppt
  • 海阳市建设工程交易中心网站品牌推广的作用
  • 江西省住房和城乡建设网站成都网站优化seo
  • java资源网站云优化
  • 小程序源码大全网络seo关键词优化技巧
  • 服务佳的小企业网站建设ip子域名大全
  • 网页与制作唐山seo推广公司
  • 自己做的网站怎么弄到网上在线网页制作
  • 电商网站 设计方案百度的排名规则详解
  • 福建省建设厅网站余外链链接平台
  • 广告营销网站市场推广方案
  • 徐州企业做网站软文是什么文章
  • 网站代码备份如何优化seo
  • 百度网站公司信息推广怎么做天津做网站的网络公司
  • wordpress在线pdfseo百度站长工具查询
  • 太仓网站建设有限公司网站设计公司怎么样
  • 网站去哪做在线crm软件
  • 做360手机网站快速汕头seo排名收费
  • 网站建设总做总结宜兴百度推广公司
  • 做毕业网站的周记外贸建站优化
  • 南昌市住房和城乡建设局网站百度官网推广平台电话