Git Product home page Git Product logo

emot's Introduction

emot's People

Contributors

lete114 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

emot's Issues

切换页面出现两个emot的问题

大佬,我用的时候发现了一个奇怪的问题,可以用这个链接测试:http://space.eyescode.top/about

第一次进入正常:

点进别的页面,再回来,就变成这样了:

代码是这样的,覆盖了一点样式:

<template>
  <div class="emojiInput">
    <textarea
      class="emoji-textarea"
      :placeholder="placeholder"
      v-model="text"
      @blur="changeValue"
    ></textarea>
    <div class="emoji-container"></div>
  </div>
</template>

<script lang="ts">
import { defineComponent, onMounted, ref, watch, inject } from "vue";
import resource from "@/config/resource";
import Emot from "emot";
import { HelpInterface } from "@/d.ts/plugin";
import { goComment } from "@/components/general/comment/businessTs/commentProcess";
import { commentContext } from "@/components/general/comment/config";

export default defineComponent({
  emits: ["changeValue"],
  setup(props, ctx) {
    const $utils = inject<HelpInterface>("$utils")!;

    let text = ref("");
    let emot: any;
    let isShow = false;
    let emotItems: HTMLElement;

    function changeValue() {
      ctx.emit(
        "changeValue",
        emot.get().content.replace(/^\[#[0-9]+@.{2,10}\]:/, ""), 
        emot.get().contentHTML
      );
    }

    function initEmot() {
      emot = new Emot({
        el: ".emoji-container",
        target: ".emoji-textarea",
        emotMaps: resource.emojiJson,
      });
    }

    function containerSwatch() {
      isShow = !isShow;
      emotItems.style.display = isShow ? "block" : "none";
    }

    function clearText() {
      text.value = "";
      emotItems.style.display ="none";
    }

    let clear = setInterval(() => {
      if(document.querySelector(".emot-packages")) {
        emotItems = document.querySelector(".emot-items") as HTMLElement;
        (document.querySelector(".emot-packages") as HTMLElement).onclick = containerSwatch;
        clearInterval(clear);
      }
    }, 1000);

    watch(
        () => goComment.goCommentSentry.value,
        () => {
          text.value = "[#" + goComment.objectId.value + "@" + goComment.replyName.value + "]:";
          $utils.cursorMove(document.querySelector(".emoji-textarea"), text.value.length);
        }
    )

    onMounted(() => {
      initEmot();
    });

    return {
      text,
      placeholder: commentContext.inputPlaceholder,
      changeValue,
      clearText
    };
  },
});
</script>

<style lang="scss" scoped>
@import "@/assets/scss/index.scss";

:deep(.emoji-container > .emot) {
  border: none;
  background: none;
  .emot-packages {
    border-top: none;
    width: 40px;
    .emot-package-active {
      background: none;
    }
  }
  .emot-items {
    resize: none;
    display: none;
    .emot-item {
      margin: 0;
    }
  }
}

.emojiInput {
  width: calc(100% - 25px);
  margin-left: 2.5px;
  .emoji-textarea {
    width: 100%;
    height: 80px;
    color: $normal;
    font-family: "eyes";
    background: none;
    border: none;
    border-radius: 5px;
    outline: none;
    resize: vertical;
    box-shadow: 0 0 5px rgba($color: $black, $alpha: 0.7);
    -webkit-box-shadow: 0 0 5px rgba($color: $black, $alpha: 0.7);
    -moz-box-shadow: 0 0 5px rgba($color: $black, $alpha: 0.7);
    padding: 10px;
  }
}
</style>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.