New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vditor

Package Overview
Dependencies
Maintainers
1
Versions
328
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vditor - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

src/assets/emoji/doge.png

2

dist/vendors~vditor.bundle.js

@@ -1,1 +0,1 @@

(window.webpackJsonpVditor=window.webpackJsonpVditor||[]).push([[2],{27:function(e,a,o){"use strict";o.r(a),o.d(a,"getAllEmoji",function(){return r});var r=function(e){return{"+1":"👍","-1":"👎",100:"💯",1234:"🔢","8ball":"🎱",a:"🅰",ab:"🆎",abc:"🔤",abcd:"🔡",accept:"🉑",aerial_tramway:"🚡",airplane:"✈",alarm_clock:"⏰",alien:"👽",ambulance:"🚑",anchor:"⚓",angel:"👼",anger:"💢",angry:"😠",anguished:"😧",ant:"🐜",apple:"🍎",aquarius:"♒",aries:"♈",arrow_backward:"◀",arrow_double_down:"⏬",arrow_double_up:"⏫",arrow_down:"⬇",arrow_down_small:"🔽",arrow_forward:"▶",arrow_heading_down:"⤵",arrow_heading_up:"⤴",arrow_left:"⬅",arrow_lower_left:"↙",arrow_lower_right:"↘",arrow_right:"➡",arrow_right_hook:"↪",arrow_up:"⬆",arrow_up_down:"↕",arrow_up_small:"🔼",arrow_upper_left:"↖",arrow_upper_right:"↗",arrows_clockwise:"🔃",arrows_counterclockwise:"🔄",art:"🎨",articulated_lorry:"🚛",astonished:"😲",atm:"🏧",b:"🅱",baby:"👶",baby_bottle:"🍼",baby_chick:"🐤",baby_symbol:"🚼",back:"🔙",baggage_claim:"🛄",balloon:"🎈",ballot_box_with_check:"☑",bamboo:"🎍",banana:"🍌",bangbang:"‼",bank:"🏦",bar_chart:"📊",barber:"💈",baseball:"⚾",basketball:"🏀",bath:"🛀",bathtub:"🛁",battery:"🔋",bear:"🐻",bee:"🐝",beer:"🍺",beers:"🍻",beetle:"🐞",beginner:"🔰",bell:"🔔",bento:"🍱",bicyclist:"🚴",bike:"🚲",bikini:"👙",bird:"🐦",birthday:"🎂",black_circle:"⚫",black_joker:"🃏",black_large_square:"⬛",black_medium_small_square:"◾",black_medium_square:"◼",black_nib:"✒",black_small_square:"▪",black_square_button:"🔲",blossom:"🌼",blowfish:"🐡",blue_book:"📘",blue_car:"🚙",blue_heart:"💙",blush:"😊",boar:"🐗",boat:"⛵",bomb:"💣",book:"📖",bookmark:"🔖",bookmark_tabs:"📑",books:"📚",boom:"💥",boot:"👢",bouquet:"💐",bow:"🙇",bowling:"🎳",boy:"👦",bread:"🍞",bride_with_veil:"👰",bridge_at_night:"🌉",briefcase:"💼",broken_heart:"💔",bug:"🐛",bulb:"💡",bullettrain_front:"🚅",bullettrain_side:"🚄",bus:"🚌",busstop:"🚏",bust_in_silhouette:"👤",busts_in_silhouette:"👥",c:e+"/c.png",cactus:"🌵",cake:"🍰",calendar:"📆",calling:"📲",camel:"🐫",camera:"📷",cancer:"🦀",candy:"🍬",capital_abcd:"🔠",capricorn:"♑",car:"🚗",card_index:"📇",carousel_horse:"🎠",cat:"🐱",cat2:"🐈",cd:"🇨🇩",chart:"💹",chart_with_downwards_trend:"📉",chart_with_upwards_trend:"📈",checkered_flag:"🏁",cherries:"🍒",cherry_blossom:"🌸",chestnut:"🌰",chicken:"🐔",children_crossing:"🚸",chocolate_bar:"🍫",christmas_tree:"🎄",church:"⛪",cinema:"🎦",circus_tent:"🎪",city_sunrise:"🌇",city_sunset:"🌆",cl:"🇨🇱",clap:"👏",clapper:"🎬",clipboard:"📋",clock1:"🕐",clock10:"🕙",clock1030:"🕥",clock11:"🕚",clock1130:"🕦",clock12:"🕛",clock1230:"🕧",clock130:"🕜",clock2:"🕑",clock230:"🕝",clock3:"🕒",clock330:"🕞",clock4:"🕓",clock430:"🕟",clock5:"🕔",clock530:"🕠",clock6:"🕕",clock630:"🕡",clock7:"🕖",clock730:"🕢",clock8:"🕗",clock830:"🕣",clock9:"🕘",clock930:"🕤",closed_book:"📕",closed_lock_with_key:"🔐",closed_umbrella:"🌂",cloud:"☁",clubs:"♣",cn:"🇨🇳",cocktail:"🍸",coffee:"☕",cold_sweat:"😰",collision:"💥",computer:"💻",confetti_ball:"🎊",confounded:"😖",confused:"😕",congratulations:"㊗",construction:"🚧",construction_worker:"👷",convenience_store:"🏪",cookie:"🍪",cool:"🆒",cop:"👮",copyright:"©",corn:"🌽",couple:"👫",couple_with_heart:"💑",couplekiss:"💏",cow:"🐮",cow2:"🐄",credit_card:"💳",crescent_moon:"🌙",crocodile:"🐊",crossed_flags:"🎌",crown:"👑",cry:"😢",crying_cat_face:"😿",crystal_ball:"🔮",cupid:"💘",curly_loop:"➰",currency_exchange:"💱",curry:"🍛",custard:"🍮",customs:"🛃",cyclone:"🌀",d:e+"/d.png",dancer:"💃",dancers:"👯",dango:"🍡",dart:"🎯",dash:"💨",date:"📅",de:"🇩🇪",deciduous_tree:"🌳",department_store:"🏬",diamond_shape_with_a_dot_inside:"💠",diamonds:"♦",disappointed:"😞",disappointed_relieved:"😥",dizzy:"💫",dizzy_face:"😵",do_not_litter:"🚯",dog:"🐶",dog2:"🐕",dollar:"💵",dolls:"🎎",dolphin:"🐬",door:"🚪",doughnut:"🍩",dragon:"🐉",dragon_face:"🐲",dress:"👗",dromedary_camel:"🐪",droplet:"💧",dvd:"📀","e-mail":"📧",e50a:e+"/e50a.png",ear:"👂",ear_of_rice:"🌾",earth_africa:"🌍",earth_americas:"🌎",earth_asia:"🌏",egg:"🥚",eggplant:"🍆",eight:"8⃣",eight_pointed_black_star:"✴",eight_spoked_asterisk:"✳",electric_plug:"🔌",elephant:"🐘",email:"✉",end:"🔚",envelope:"✉",es:"🇪🇸",euro:"💶",european_castle:"🏰",european_post_office:"🏤",evergreen_tree:"🌲",exclamation:"❗",expressionless:"😑",eyeglasses:"👓",eyes:"👀",f:e+"/f.png",facepunch:"👊",factory:"🏭",fallen_leaf:"🍂",family:"👪",fast_forward:"⏩",fax:"📠",fearful:"😨",feet:"🐾",ferris_wheel:"🎡",file_folder:"📁",fire:"🔥",fire_engine:"🚒",fireworks:"🎆",first_quarter_moon:"🌓",first_quarter_moon_with_face:"🌛",fish:"🐟",fish_cake:"🍥",fishing_pole_and_fish:"🎣",fist:"✊",five:"5⃣",flags:"🎏",flashlight:"🔦",floppy_disk:"💾",flower_playing_cards:"🎴",flushed:"😳",foggy:"🌁",football:"🏈",fork_and_knife:"🍴",fountain:"⛲",four:"4⃣",four_leaf_clover:"🍀",fr:"🇫🇷",free:"🆓",fried_shrimp:"🍤",fries:"🍟",frog:"🐸",frowning:"😦",fuelpump:"⛽",full_moon:"🌕",full_moon_with_face:"🌝",g:e+"/g.png",game_die:"🎲",gb:"🇬🇧",gem:"💎",gemini:"♊",ghost:"👻",gift:"🎁",gift_heart:"💝",girl:"👧",globe_with_meridians:"🌐",goat:"🐐",golf:"⛳",grapes:"🍇",green_apple:"🍏",green_book:"📗",green_heart:"💚",grey_exclamation:"❕",grey_question:"❔",grimacing:"😬",grin:"😁",grinning:"😀",guardsman:"💂",guitar:"🎸",gun:"🔫",haircut:"💇",hamburger:"🍔",hammer:"🔨",hamster:"🐹",hand:"✋",handbag:"👜",hankey:"💩",hash:"#⃣",hatched_chick:"🐥",hatching_chick:"🐣",headphones:"🎧",hear_no_evil:"🙉",heart:"❤️",heart_decoration:"💟",heart_eyes:"😍",heart_eyes_cat:"😻",heartbeat:"💓",heartpulse:"💗",hearts:"♥️",heavy_check_mark:"✔",heavy_division_sign:"➗",heavy_dollar_sign:"💲",heavy_exclamation_mark:"❗",heavy_minus_sign:"➖",heavy_multiplication_x:"✖",heavy_plus_sign:"➕",helicopter:"🚁",herb:"🌿",hibiscus:"🌺",high_brightness:"🔆",high_heel:"👠",hocho:"🔪",honey_pot:"🍯",honeybee:"🐝",horse:"🐴",horse_racing:"🏇",hospital:"🏥",hotel:"🏨",hotsprings:"♨",hourglass:"⌛",hourglass_flowing_sand:"⏳",house:"🏠",house_with_garden:"🏡",huaji:e+"/huaji.gif",hushed:"😯",i:e+"/i.png",ice_cream:"🍨",icecream:"🍦",id:"🇮🇩",ideograph_advantage:"🉐",imp:"👿",inbox_tray:"📥",incoming_envelope:"📨",information_desk_person:"💁",information_source:"ℹ",innocent:"😇",interrobang:"⁉",iphone:"📱",it:"🇮🇹",izakaya_lantern:"🏮",j:e+"/j.png",jack_o_lantern:"🎃",japan:"🗾",japanese_castle:"🏯",japanese_goblin:"👺",japanese_ogre:"👹",jeans:"👖",joy:"😂",joy_cat:"😹",jp:"🇯🇵",k:e+"/k.png",key:"🔑",keycap_ten:"🔟",kimono:"👘",kiss:"💋",kissing:"😗",kissing_cat:"😽",kissing_closed_eyes:"😚",kissing_heart:"😘",kissing_smiling_eyes:"😙",koala:"🐨",koko:"🈁",kr:"🇰🇷",large_blue_circle:"🔵",large_blue_diamond:"🔷",large_orange_diamond:"🔶",last_quarter_moon:"🌗",last_quarter_moon_with_face:"🌜",laughing:"😆",leaves:"🍃",ledger:"📒",left_luggage:"🛅",left_right_arrow:"↔",leftwards_arrow_with_hook:"↩",lemon:"🍋",leo:"♌",leopard:"🐆",libra:"♎",light_rail:"🚈",link:"🔗",lips:"👄",lipstick:"💄",lock:"🔒",lock_with_ink_pen:"🔏",lollipop:"🍭",loop:"➿",loudspeaker:"📢",love_hotel:"🏩",love_letter:"💌",low_brightness:"🔅",m:"Ⓜ",mag:"🔍",mag_right:"🔎",mahjong:"🀄",mailbox:"📫",mailbox_closed:"📪",mailbox_with_mail:"📬",mailbox_with_no_mail:"📭",man:"👨",man_with_gua_pi_mao:"👲",man_with_turban:"👳",mans_shoe:"👞",maple_leaf:"🍁",mask:"😷",massage:"💆",meat_on_bone:"🍖",mega:"📣",melon:"🍈",memo:"📝",mens:"🚹",metro:"🚇",microphone:"🎤",microscope:"🔬",milky_way:"🌌",minibus:"🚐",minidisc:"💽",mobile_phone_off:"📴",money_with_wings:"💸",moneybag:"💰",monkey:"🐒",monkey_face:"🐵",monorail:"🚝",mortar_board:"🎓",mount_fuji:"🗻",mountain_bicyclist:"🚵",mountain_cableway:"🚠",mountain_railway:"🚞",mouse:"🐭",mouse2:"🐁",movie_camera:"🎥",moyai:"🗿",muscle:"💪",mushroom:"🍄",musical_keyboard:"🎹",musical_note:"🎵",musical_score:"🎼",mute:"🔇",nail_care:"💅",name_badge:"📛",necktie:"👔",negative_squared_cross_mark:"❎",neutral_face:"😐",new:"🆕",new_moon:"🌑",new_moon_with_face:"🌚",newspaper:"📰",ng:"🇳🇬",nine:"9⃣",no_bell:"🔕",no_bicycles:"🚳",no_entry:"⛔",no_entry_sign:"🚫",no_good:"🙅",no_mobile_phones:"📵",no_mouth:"😶",no_pedestrians:"🚷",no_smoking:"🚭","non-potable_water":"🚱",nose:"👃",notebook:"📓",notebook_with_decorative_cover:"📔",notes:"🎶",nut_and_bolt:"🔩",o:"⭕",o2:"🅾",ocean:"🌊",octocat:e+"/octocat.png",octopus:"🐙",oden:"🍢",office:"🏢",ok:"🆗",ok_hand:"👌",ok_woman:"🙆",older_man:"👴",older_woman:"👵",on:"🔛",oncoming_automobile:"🚘",oncoming_bus:"🚍",oncoming_police_car:"🚔",oncoming_taxi:"🚖",one:"1⃣",open_file_folder:"📂",open_hands:"👐",open_mouth:"😮",ophiuchus:"⛎",orange_book:"📙",outbox_tray:"📤",ox:"🐂",package:"📦",page_facing_up:"📄",page_with_curl:"📃",pager:"📟",palm_tree:"🌴",panda_face:"🐼",paperclip:"📎",parking:"🅿",part_alternation_mark:"〽",partly_sunny:"⛅",passport_control:"🛂",paw_prints:"🐾",peach:"🍑",pear:"🍐",pencil:"📝",pencil2:"✏",penguin:"🐧",pensive:"😔",performing_arts:"🎭",persevere:"😣",person_frowning:"🙍",person_with_blond_hair:"👱",person_with_pouting_face:"🙎",phone:"☎",pig:"🐷",pig2:"🐖",pig_nose:"🐽",pill:"💊",pineapple:"🍍",pisces:"♓",pizza:"🍕",point_down:"👇",point_left:"👈",point_right:"👉",point_up:"☝",point_up_2:"👆",police_car:"🚓",poodle:"🐩",poop:"💩",postal_horn:"📯",postbox:"📮",potable_water:"🚰",pouch:"👝",poultry_leg:"🍗",pound:"💷",pouting_cat:"😾",pray:"🙏",princess:"👸",punch:"👊",purple_heart:"💜",purse:"👛",pushpin:"📌",put_litter_in_its_place:"🚮",question:"❓",r:e+"/r.png",rabbit:"🐰",rabbit2:"🐇",racehorse:"🐎",radio:"📻",radio_button:"🔘",rage:"😡",railway_car:"🚃",rainbow:"🌈",raised_hand:"✋",raised_hands:"🙌",raising_hand:"🙋",ram:"🐏",ramen:"🍜",rat:"🐀",recycle:"♻",red_car:"🚗",red_circle:"🔴",registered:"®",relaxed:"☺",relieved:"😌",repeat:"🔁",repeat_one:"🔂",restroom:"🚻",revolving_hearts:"💞",rewind:"⏪",ribbon:"🎀",rice:"🍚",rice_ball:"🍙",rice_cracker:"🍘",rice_scene:"🎑",ring:"💍",rocket:"🚀",roller_coaster:"🎢",rooster:"🐓",rose:"🌹",rotating_light:"🚨",round_pushpin:"📍",rowboat:"🚣",ru:"🇷🇺",rugby_football:"🏉",running:"🏃",running_shirt_with_sash:"🎽",sa:"🇸🇦",sagittarius:"♐",sailboat:"⛵",sake:"🍶",sandal:"👡",santa:"🎅",satellite:"🛰",satisfied:"😆",saxophone:"🎷",school:"🏫",school_satchel:"🎒",scissors:"✂",scorpius:"♏",scream:"😱",scream_cat:"🙀",scroll:"📜",seat:"💺",secret:"㊙",see_no_evil:"🙈",seedling:"🌱",seven:"7⃣",shaved_ice:"🍧",sheep:"🐑",shell:"🐚",ship:"🚢",shirt:"👕",shoe:"👞",shower:"🚿",signal_strength:"📶",six:"6⃣",six_pointed_star:"🔯",ski:"🎿",skull:"💀",sleeping:"😴",sleepy:"😪",slot_machine:"🎰",small_blue_diamond:"🔹",small_orange_diamond:"🔸",small_red_triangle:"🔺",small_red_triangle_down:"🔻",smile:"😄",smile_cat:"😸",smiley:"😃",smiley_cat:"😺",smiling_imp:"😈",smirk:"😏",smirk_cat:"😼",smoking:"🚬",snail:"🐌",snake:"🐍",snowboarder:"🏂",snowflake:"❄",snowman:"⛄",sob:"😭",soccer:"⚽",soon:"🔜",sos:"🆘",sound:"🔉",space_invader:"👾",spades:"♠",spaghetti:"🍝",sparkle:"❇",sparkler:"🎇",sparkles:"✨",sparkling_heart:"💖",speak_no_evil:"🙊",speaker:"🔈",speech_balloon:"💬",speedboat:"🚤",squirrel:"🐿",star:"⭐",star2:"🌟",stars:"🌠",station:"🚉",statue_of_liberty:"🗽",steam_locomotive:"🚂",stew:"🍲",straight_ruler:"📏",strawberry:"🍓",stuck_out_tongue:"😛",stuck_out_tongue_closed_eyes:"😝",stuck_out_tongue_winking_eye:"😜",sun_with_face:"🌞",sunflower:"🌻",sunglasses:"😎",sunny:"☀",sunrise:"🌅",sunrise_over_mountains:"🌄",surfer:"🏄",sushi:"🍣",suspension_railway:"🚟",sweat:"😓",sweat_drops:"💦",sweat_smile:"😅",sweet_potato:"🍠",swimmer:"🏊",symbols:"🔣",syringe:"💉",tada:"🎉",tanabata_tree:"🎋",tangerine:"🍊",taurus:"♉",taxi:"🚕",tea:"🍵",telephone:"☎",telephone_receiver:"📞",telescope:"🔭",tennis:"🎾",tent:"🏕",thought_balloon:"💭",three:"3⃣",thumbsdown:"👎",thumbsup:"👍",ticket:"🎫",tiger:"🐯",tiger2:"🐅",tired_face:"😫",tm:"🇹🇲",toilet:"🚽",tokyo_tower:"🗼",tomato:"🍅",tongue:"👅",top:"🔝",tophat:"🎩",tractor:"🚜",traffic_light:"🚥",train:"🚋",train2:"🚆",tram:"🚊",triangular_flag_on_post:"🚩",triangular_ruler:"📐",trident:"🔱",triumph:"😤",trolleybus:"🚎",trollface:e+"/trollface.png",trophy:"🏆",tropical_drink:"🍹",tropical_fish:"🐠",truck:"🚚",trumpet:"🎺",tshirt:"👕",tulip:"🌷",turtle:"🐢",tv:"🇹🇻",twisted_rightwards_arrows:"🔀",two:"2⃣",two_hearts:"💕",two_men_holding_hands:"👬",two_women_holding_hands:"👭",u:e+"/u.png",u5272:"🈹",u5408:"🈴",u55b6:"🈺",u6307:"🈯",u6708:"🈷",u6709:"🈶",u6e80:"🈵",u7121:"🈚",u7533:"🈸",u7981:"🈲",u7a7a:"🈳",umbrella:"☔",unamused:"😒",underage:"🔞",unicorn_face:"🦄",unlock:"🔓",up:"🆙",us:"🇺🇸",v:"✌",vertical_traffic_light:"🚦",vhs:"📼",vibration_mode:"📳",video_camera:"📹",video_game:"🎮",violin:"🎻",virgo:"♍",volcano:"🌋",vs:"🆚",walking:"🚶",waning_crescent_moon:"🌘",waning_gibbous_moon:"🌖",warning:"⚠",watch:"⌚",water_buffalo:"🐃",watermelon:"🍉",wave:"👋",wavy_dash:"〰",waxing_crescent_moon:"🌒",waxing_gibbous_moon:"🌔",wc:"🚾",weary:"😩",wedding:"💒",whale:"🐳",whale2:"🐋",wheelchair:"♿",white_check_mark:"✅",white_circle:"⚪",white_flower:"💮",white_large_square:"⬜",white_medium_small_square:"◽",white_medium_square:"◻",white_small_square:"▫",white_square_button:"🔳",wind_chime:"🎐",wine_glass:"🍷",wink:"😉",wolf:"🐺",woman:"👩",womans_clothes:"👚",womans_hat:"👒",womens:"🚺",worried:"😟",wrench:"🔧",x:"❌",yellow_heart:"💛",yen:"💴",yum:"😋",zap:"⚡",zero:"0⃣",zzz:"💤"}}}}]);
(window.webpackJsonpVditor=window.webpackJsonpVditor||[]).push([[2],{27:function(e,a,o){"use strict";o.r(a),o.d(a,"getAllEmoji",function(){return r});var r=function(e){return{"+1":"👍","-1":"👎",100:"💯",1234:"🔢","8ball":"🎱",a:"🅰",ab:"🆎",abc:"🔤",abcd:"🔡",accept:"🉑",aerial_tramway:"🚡",airplane:"✈",alarm_clock:"⏰",alien:"👽",ambulance:"🚑",anchor:"⚓",angel:"👼",anger:"💢",angry:"😠",anguished:"😧",ant:"🐜",apple:"🍎",aquarius:"♒",aries:"♈",arrow_backward:"◀",arrow_double_down:"⏬",arrow_double_up:"⏫",arrow_down:"⬇",arrow_down_small:"🔽",arrow_forward:"▶",arrow_heading_down:"⤵",arrow_heading_up:"⤴",arrow_left:"⬅",arrow_lower_left:"↙",arrow_lower_right:"↘",arrow_right:"➡",arrow_right_hook:"↪",arrow_up:"⬆",arrow_up_down:"↕",arrow_up_small:"🔼",arrow_upper_left:"↖",arrow_upper_right:"↗",arrows_clockwise:"🔃",arrows_counterclockwise:"🔄",art:"🎨",articulated_lorry:"🚛",astonished:"😲",atm:"🏧",b:"🅱",baby:"👶",baby_bottle:"🍼",baby_chick:"🐤",baby_symbol:"🚼",back:"🔙",baggage_claim:"🛄",balloon:"🎈",ballot_box_with_check:"☑",bamboo:"🎍",banana:"🍌",bangbang:"‼",bank:"🏦",bar_chart:"📊",barber:"💈",baseball:"⚾",basketball:"🏀",bath:"🛀",bathtub:"🛁",battery:"🔋",bear:"🐻",bee:"🐝",beer:"🍺",beers:"🍻",beetle:"🐞",beginner:"🔰",bell:"🔔",bento:"🍱",bicyclist:"🚴",bike:"🚲",bikini:"👙",bird:"🐦",birthday:"🎂",black_circle:"⚫",black_joker:"🃏",black_large_square:"⬛",black_medium_small_square:"◾",black_medium_square:"◼",black_nib:"✒",black_small_square:"▪",black_square_button:"🔲",blossom:"🌼",blowfish:"🐡",blue_book:"📘",blue_car:"🚙",blue_heart:"💙",blush:"😊",boar:"🐗",boat:"⛵",bomb:"💣",book:"📖",bookmark:"🔖",bookmark_tabs:"📑",books:"📚",boom:"💥",boot:"👢",bouquet:"💐",bow:"🙇",bowling:"🎳",boy:"👦",bread:"🍞",bride_with_veil:"👰",bridge_at_night:"🌉",briefcase:"💼",broken_heart:"💔",bug:"🐛",bulb:"💡",bullettrain_front:"🚅",bullettrain_side:"🚄",bus:"🚌",busstop:"🚏",bust_in_silhouette:"👤",busts_in_silhouette:"👥",c:e+"/c.png",cactus:"🌵",cake:"🍰",calendar:"📆",calling:"📲",camel:"🐫",camera:"📷",cancer:"🦀",candy:"🍬",capital_abcd:"🔠",capricorn:"♑",car:"🚗",card_index:"📇",carousel_horse:"🎠",cat:"🐱",cat2:"🐈",cd:"🇨🇩",chart:"💹",chart_with_downwards_trend:"📉",chart_with_upwards_trend:"📈",checkered_flag:"🏁",cherries:"🍒",cherry_blossom:"🌸",chestnut:"🌰",chicken:"🐔",children_crossing:"🚸",chocolate_bar:"🍫",christmas_tree:"🎄",church:"⛪",cinema:"🎦",circus_tent:"🎪",city_sunrise:"🌇",city_sunset:"🌆",cl:"🇨🇱",clap:"👏",clapper:"🎬",clipboard:"📋",clock1:"🕐",clock10:"🕙",clock1030:"🕥",clock11:"🕚",clock1130:"🕦",clock12:"🕛",clock1230:"🕧",clock130:"🕜",clock2:"🕑",clock230:"🕝",clock3:"🕒",clock330:"🕞",clock4:"🕓",clock430:"🕟",clock5:"🕔",clock530:"🕠",clock6:"🕕",clock630:"🕡",clock7:"🕖",clock730:"🕢",clock8:"🕗",clock830:"🕣",clock9:"🕘",clock930:"🕤",closed_book:"📕",closed_lock_with_key:"🔐",closed_umbrella:"🌂",cloud:"☁",clubs:"♣",cn:"🇨🇳",cocktail:"🍸",coffee:"☕",cold_sweat:"😰",collision:"💥",computer:"💻",confetti_ball:"🎊",confounded:"😖",confused:"😕",congratulations:"㊗",construction:"🚧",construction_worker:"👷",convenience_store:"🏪",cookie:"🍪",cool:"🆒",cop:"👮",copyright:"©",corn:"🌽",couple:"👫",couple_with_heart:"💑",couplekiss:"💏",cow:"🐮",cow2:"🐄",credit_card:"💳",crescent_moon:"🌙",crocodile:"🐊",crossed_flags:"🎌",crown:"👑",cry:"😢",crying_cat_face:"😿",crystal_ball:"🔮",cupid:"💘",curly_loop:"➰",currency_exchange:"💱",curry:"🍛",custard:"🍮",customs:"🛃",cyclone:"🌀",d:e+"/d.png",dancer:"💃",dancers:"👯",dango:"🍡",dart:"🎯",dash:"💨",date:"📅",de:"🇩🇪",deciduous_tree:"🌳",department_store:"🏬",diamond_shape_with_a_dot_inside:"💠",diamonds:"♦",disappointed:"😞",disappointed_relieved:"😥",dizzy:"💫",dizzy_face:"😵",do_not_litter:"🚯",dog:"🐶",dog2:"🐕",doge:e+"/doge.png",dollar:"💵",dolls:"🎎",dolphin:"🐬",door:"🚪",doughnut:"🍩",dragon:"🐉",dragon_face:"🐲",dress:"👗",dromedary_camel:"🐪",droplet:"💧",dvd:"📀","e-mail":"📧",e50a:e+"/e50a.png",ear:"👂",ear_of_rice:"🌾",earth_africa:"🌍",earth_americas:"🌎",earth_asia:"🌏",egg:"🥚",eggplant:"🍆",eight:"8⃣",eight_pointed_black_star:"✴",eight_spoked_asterisk:"✳",electric_plug:"🔌",elephant:"🐘",email:"✉",end:"🔚",envelope:"✉",es:"🇪🇸",euro:"💶",european_castle:"🏰",european_post_office:"🏤",evergreen_tree:"🌲",exclamation:"❗",expressionless:"😑",eyeglasses:"👓",eyes:"👀",f:e+"/f.png",facepunch:"👊",factory:"🏭",fallen_leaf:"🍂",family:"👪",fast_forward:"⏩",fax:"📠",fearful:"😨",feet:"🐾",ferris_wheel:"🎡",file_folder:"📁",fire:"🔥",fire_engine:"🚒",fireworks:"🎆",first_quarter_moon:"🌓",first_quarter_moon_with_face:"🌛",fish:"🐟",fish_cake:"🍥",fishing_pole_and_fish:"🎣",fist:"✊",five:"5⃣",flags:"🎏",flashlight:"🔦",floppy_disk:"💾",flower_playing_cards:"🎴",flushed:"😳",foggy:"🌁",football:"🏈",fork_and_knife:"🍴",fountain:"⛲",four:"4⃣",four_leaf_clover:"🍀",fr:"🇫🇷",free:"🆓",fried_shrimp:"🍤",fries:"🍟",frog:"🐸",frowning:"😦",fuelpump:"⛽",full_moon:"🌕",full_moon_with_face:"🌝",g:e+"/g.png",game_die:"🎲",gb:"🇬🇧",gem:"💎",gemini:"♊",ghost:"👻",gift:"🎁",gift_heart:"💝",girl:"👧",globe_with_meridians:"🌐",goat:"🐐",golf:"⛳",grapes:"🍇",green_apple:"🍏",green_book:"📗",green_heart:"💚",grey_exclamation:"❕",grey_question:"❔",grimacing:"😬",grin:"😁",grinning:"😀",guardsman:"💂",guitar:"🎸",gun:"🔫",haircut:"💇",hamburger:"🍔",hammer:"🔨",hamster:"🐹",hand:"✋",handbag:"👜",hankey:"💩",hash:"#⃣",hatched_chick:"🐥",hatching_chick:"🐣",headphones:"🎧",hear_no_evil:"🙉",heart:"❤️",heart_decoration:"💟",heart_eyes:"😍",heart_eyes_cat:"😻",heartbeat:"💓",heartpulse:"💗",hearts:"♥️",heavy_check_mark:"✔",heavy_division_sign:"➗",heavy_dollar_sign:"💲",heavy_exclamation_mark:"❗",heavy_minus_sign:"➖",heavy_multiplication_x:"✖",heavy_plus_sign:"➕",helicopter:"🚁",herb:"🌿",hibiscus:"🌺",high_brightness:"🔆",high_heel:"👠",hocho:"🔪",honey_pot:"🍯",honeybee:"🐝",horse:"🐴",horse_racing:"🏇",hospital:"🏥",hotel:"🏨",hotsprings:"♨",hourglass:"⌛",hourglass_flowing_sand:"⏳",house:"🏠",house_with_garden:"🏡",huaji:e+"/huaji.gif",hushed:"😯",i:e+"/i.png",ice_cream:"🍨",icecream:"🍦",id:"🇮🇩",ideograph_advantage:"🉐",imp:"👿",inbox_tray:"📥",incoming_envelope:"📨",information_desk_person:"💁",information_source:"ℹ",innocent:"😇",interrobang:"⁉",iphone:"📱",it:"🇮🇹",izakaya_lantern:"🏮",j:e+"/j.png",jack_o_lantern:"🎃",japan:"🗾",japanese_castle:"🏯",japanese_goblin:"👺",japanese_ogre:"👹",jeans:"👖",joy:"😂",joy_cat:"😹",jp:"🇯🇵",k:e+"/k.png",key:"🔑",keycap_ten:"🔟",kimono:"👘",kiss:"💋",kissing:"😗",kissing_cat:"😽",kissing_closed_eyes:"😚",kissing_heart:"😘",kissing_smiling_eyes:"😙",koala:"🐨",koko:"🈁",kr:"🇰🇷",large_blue_circle:"🔵",large_blue_diamond:"🔷",large_orange_diamond:"🔶",last_quarter_moon:"🌗",last_quarter_moon_with_face:"🌜",laughing:"😆",leaves:"🍃",ledger:"📒",left_luggage:"🛅",left_right_arrow:"↔",leftwards_arrow_with_hook:"↩",lemon:"🍋",leo:"♌",leopard:"🐆",libra:"♎",light_rail:"🚈",link:"🔗",lips:"👄",lipstick:"💄",lock:"🔒",lock_with_ink_pen:"🔏",lollipop:"🍭",loop:"➿",loudspeaker:"📢",love_hotel:"🏩",love_letter:"💌",low_brightness:"🔅",m:"Ⓜ",mag:"🔍",mag_right:"🔎",mahjong:"🀄",mailbox:"📫",mailbox_closed:"📪",mailbox_with_mail:"📬",mailbox_with_no_mail:"📭",man:"👨",man_with_gua_pi_mao:"👲",man_with_turban:"👳",mans_shoe:"👞",maple_leaf:"🍁",mask:"😷",massage:"💆",meat_on_bone:"🍖",mega:"📣",melon:"🍈",memo:"📝",mens:"🚹",metro:"🚇",microphone:"🎤",microscope:"🔬",milky_way:"🌌",minibus:"🚐",minidisc:"💽",mobile_phone_off:"📴",money_with_wings:"💸",moneybag:"💰",monkey:"🐒",monkey_face:"🐵",monorail:"🚝",mortar_board:"🎓",mount_fuji:"🗻",mountain_bicyclist:"🚵",mountain_cableway:"🚠",mountain_railway:"🚞",mouse:"🐭",mouse2:"🐁",movie_camera:"🎥",moyai:"🗿",muscle:"💪",mushroom:"🍄",musical_keyboard:"🎹",musical_note:"🎵",musical_score:"🎼",mute:"🔇",nail_care:"💅",name_badge:"📛",necktie:"👔",negative_squared_cross_mark:"❎",neutral_face:"😐",new:"🆕",new_moon:"🌑",new_moon_with_face:"🌚",newspaper:"📰",ng:"🇳🇬",nine:"9⃣",no_bell:"🔕",no_bicycles:"🚳",no_entry:"⛔",no_entry_sign:"🚫",no_good:"🙅",no_mobile_phones:"📵",no_mouth:"😶",no_pedestrians:"🚷",no_smoking:"🚭","non-potable_water":"🚱",nose:"👃",notebook:"📓",notebook_with_decorative_cover:"📔",notes:"🎶",nut_and_bolt:"🔩",o:"⭕",o2:"🅾",ocean:"🌊",octocat:e+"/octocat.png",octopus:"🐙",oden:"🍢",office:"🏢",ok:"🆗",ok_hand:"👌",ok_woman:"🙆",older_man:"👴",older_woman:"👵",on:"🔛",oncoming_automobile:"🚘",oncoming_bus:"🚍",oncoming_police_car:"🚔",oncoming_taxi:"🚖",one:"1⃣",open_file_folder:"📂",open_hands:"👐",open_mouth:"😮",ophiuchus:"⛎",orange_book:"📙",outbox_tray:"📤",ox:"🐂",package:"📦",page_facing_up:"📄",page_with_curl:"📃",pager:"📟",palm_tree:"🌴",panda_face:"🐼",paperclip:"📎",parking:"🅿",part_alternation_mark:"〽",partly_sunny:"⛅",passport_control:"🛂",paw_prints:"🐾",peach:"🍑",pear:"🍐",pencil:"📝",pencil2:"✏",penguin:"🐧",pensive:"😔",performing_arts:"🎭",persevere:"😣",person_frowning:"🙍",person_with_blond_hair:"👱",person_with_pouting_face:"🙎",phone:"☎",pig:"🐷",pig2:"🐖",pig_nose:"🐽",pill:"💊",pineapple:"🍍",pisces:"♓",pizza:"🍕",point_down:"👇",point_left:"👈",point_right:"👉",point_up:"☝",point_up_2:"👆",police_car:"🚓",poodle:"🐩",poop:"💩",postal_horn:"📯",postbox:"📮",potable_water:"🚰",pouch:"👝",poultry_leg:"🍗",pound:"💷",pouting_cat:"😾",pray:"🙏",princess:"👸",punch:"👊",purple_heart:"💜",purse:"👛",pushpin:"📌",put_litter_in_its_place:"🚮",question:"❓",r:e+"/r.png",rabbit:"🐰",rabbit2:"🐇",racehorse:"🐎",radio:"📻",radio_button:"🔘",rage:"😡",railway_car:"🚃",rainbow:"🌈",raised_hand:"✋",raised_hands:"🙌",raising_hand:"🙋",ram:"🐏",ramen:"🍜",rat:"🐀",recycle:"♻",red_car:"🚗",red_circle:"🔴",registered:"®",relaxed:"☺",relieved:"😌",repeat:"🔁",repeat_one:"🔂",restroom:"🚻",revolving_hearts:"💞",rewind:"⏪",ribbon:"🎀",rice:"🍚",rice_ball:"🍙",rice_cracker:"🍘",rice_scene:"🎑",ring:"💍",rocket:"🚀",roller_coaster:"🎢",rooster:"🐓",rose:"🌹",rotating_light:"🚨",round_pushpin:"📍",rowboat:"🚣",ru:"🇷🇺",rugby_football:"🏉",running:"🏃",running_shirt_with_sash:"🎽",sa:"🇸🇦",sagittarius:"♐",sailboat:"⛵",sake:"🍶",sandal:"👡",santa:"🎅",satellite:"🛰",satisfied:"😆",saxophone:"🎷",school:"🏫",school_satchel:"🎒",scissors:"✂",scorpius:"♏",scream:"😱",scream_cat:"🙀",scroll:"📜",seat:"💺",secret:"㊙",see_no_evil:"🙈",seedling:"🌱",seven:"7⃣",shaved_ice:"🍧",sheep:"🐑",shell:"🐚",ship:"🚢",shirt:"👕",shoe:"👞",shower:"🚿",signal_strength:"📶",six:"6⃣",six_pointed_star:"🔯",ski:"🎿",skull:"💀",sleeping:"😴",sleepy:"😪",slot_machine:"🎰",small_blue_diamond:"🔹",small_orange_diamond:"🔸",small_red_triangle:"🔺",small_red_triangle_down:"🔻",smile:"😄",smile_cat:"😸",smiley:"😃",smiley_cat:"😺",smiling_imp:"😈",smirk:"😏",smirk_cat:"😼",smoking:"🚬",snail:"🐌",snake:"🐍",snowboarder:"🏂",snowflake:"❄",snowman:"⛄",sob:"😭",soccer:"⚽",soon:"🔜",sos:"🆘",sound:"🔉",space_invader:"👾",spades:"♠",spaghetti:"🍝",sparkle:"❇",sparkler:"🎇",sparkles:"✨",sparkling_heart:"💖",speak_no_evil:"🙊",speaker:"🔈",speech_balloon:"💬",speedboat:"🚤",squirrel:"🐿",star:"⭐",star2:"🌟",stars:"🌠",station:"🚉",statue_of_liberty:"🗽",steam_locomotive:"🚂",stew:"🍲",straight_ruler:"📏",strawberry:"🍓",stuck_out_tongue:"😛",stuck_out_tongue_closed_eyes:"😝",stuck_out_tongue_winking_eye:"😜",sun_with_face:"🌞",sunflower:"🌻",sunglasses:"😎",sunny:"☀",sunrise:"🌅",sunrise_over_mountains:"🌄",surfer:"🏄",sushi:"🍣",suspension_railway:"🚟",sweat:"😓",sweat_drops:"💦",sweat_smile:"😅",sweet_potato:"🍠",swimmer:"🏊",symbols:"🔣",syringe:"💉",tada:"🎉",tanabata_tree:"🎋",tangerine:"🍊",taurus:"♉",taxi:"🚕",tea:"🍵",telephone:"☎",telephone_receiver:"📞",telescope:"🔭",tennis:"🎾",tent:"🏕",thought_balloon:"💭",three:"3⃣",thumbsdown:"👎",thumbsup:"👍",ticket:"🎫",tiger:"🐯",tiger2:"🐅",tired_face:"😫",tm:"🇹🇲",toilet:"🚽",tokyo_tower:"🗼",tomato:"🍅",tongue:"👅",top:"🔝",tophat:"🎩",tractor:"🚜",traffic_light:"🚥",train:"🚋",train2:"🚆",tram:"🚊",triangular_flag_on_post:"🚩",triangular_ruler:"📐",trident:"🔱",triumph:"😤",trolleybus:"🚎",trollface:e+"/trollface.png",trophy:"🏆",tropical_drink:"🍹",tropical_fish:"🐠",truck:"🚚",trumpet:"🎺",tshirt:"👕",tulip:"🌷",turtle:"🐢",tv:"🇹🇻",twisted_rightwards_arrows:"🔀",two:"2⃣",two_hearts:"💕",two_men_holding_hands:"👬",two_women_holding_hands:"👭",u:e+"/u.png",u5272:"🈹",u5408:"🈴",u55b6:"🈺",u6307:"🈯",u6708:"🈷",u6709:"🈶",u6e80:"🈵",u7121:"🈚",u7533:"🈸",u7981:"🈲",u7a7a:"🈳",umbrella:"☔",unamused:"😒",underage:"🔞",unicorn_face:"🦄",unlock:"🔓",up:"🆙",us:"🇺🇸",v:"✌",vertical_traffic_light:"🚦",vhs:"📼",vibration_mode:"📳",video_camera:"📹",video_game:"🎮",violin:"🎻",virgo:"♍",volcano:"🌋",vs:"🆚",walking:"🚶",waning_crescent_moon:"🌘",waning_gibbous_moon:"🌖",warning:"⚠",watch:"⌚",water_buffalo:"🐃",watermelon:"🍉",wave:"👋",wavy_dash:"〰",waxing_crescent_moon:"🌒",waxing_gibbous_moon:"🌔",wc:"🚾",weary:"😩",wedding:"💒",whale:"🐳",whale2:"🐋",wheelchair:"♿",white_check_mark:"✅",white_circle:"⚪",white_flower:"💮",white_large_square:"⬜",white_medium_small_square:"◽",white_medium_square:"◻",white_small_square:"▫",white_square_button:"🔳",wind_chime:"🎐",wine_glass:"🍷",wink:"😉",wolf:"🐺",woman:"👩",womans_clothes:"👚",womans_hat:"👒",womens:"🚺",worried:"😟",wrench:"🔧",x:"❌",yellow_heart:"💛",yen:"💴",yum:"😋",zap:"⚡",zero:"0⃣",zzz:"💤"}}}}]);
{
"name": "vditor",
"version": "0.2.5",
"version": "0.2.6",
"description": "A markdown editor written in TypeScript",

@@ -5,0 +5,0 @@ "author": " Vanessa <v@b3log.org> (http://vanessa.b3log.org)",

import {VDITOR_VERSION} from "./ts/constants";
import {Counter} from "./ts/counter/index";
import {Editor, insertText} from "./ts/editor/index";
import {Editor, html2md, insertText} from "./ts/editor/index";
import {Hint} from "./ts/hint/index";

@@ -28,2 +28,3 @@ import {Hotkey} from "./ts/hotkey/index";

options: mergedOptions,
originalInnerHTML: document.getElementById(id).innerHTML,
};

@@ -144,4 +145,8 @@

}
public html2md(value: string) {
return html2md(this.vditor, value);
}
}
export default Vditor;

@@ -12,7 +12,17 @@ import {gfm} from "turndown-plugin-gfm/lib/turndown-plugin-gfm.es.js";

this.element.setAttribute("placeholder", vditor.options.placeholder);
if (vditor.options.editorName) {
this.element.setAttribute("name", vditor.options.editorName);
}
if (vditor.options.cache) {
this.element.value = localStorage.getItem("vditor" + vditor.id);
const localValue = localStorage.getItem("vditor" + vditor.id);
if (localValue) {
this.element.value = localValue;
} else {
this.setOriginal(vditor);
}
if (vditor.options.counter > 0) {
vditor.counter.render(this.element.value.length, vditor.options.counter);
}
} else {
this.setOriginal(vditor);
}

@@ -22,78 +32,8 @@ this.bindEvent(vditor);

private html2md(TurndownService: ITurndown, vditor: IVditor, textHTML: string, textPlain: string) {
let onlyMultiCode = false;
// no escape
TurndownService.prototype.escape = (name: string) => {
return name;
};
const turndownService = new TurndownService();
turndownService.addRule("strikethrough", {
filter: ["pre", "code"],
replacement: (content: string, node: HTMLElement) => {
if (node.parentElement.tagName === "PRE") {
return content;
}
if (content.split("\n").length > 1) {
onlyMultiCode = true;
return "```\n" + content + "\n```";
}
return "`" + content + "`";
},
});
turndownService.addRule("strikethrough", {
filter: ["img"],
replacement: (content: string, target: HTMLElement) => {
if (!target.getAttribute("src")) {
return "";
}
if (vditor.options.upload.linkToImgUrl) {
const xhr = new XMLHttpRequest();
xhr.open("POST", vditor.options.upload.linkToImgUrl);
xhr.onreadystatechange = () => {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
const responseJSON = JSON.parse(xhr.responseText);
if (responseJSON.code !== 0) {
alert(responseJSON.msg);
return;
}
const original = target.getAttribute("src");
vditor.editor.element.selectionStart =
vditor.editor.element.value.split(original)[0].length;
vditor.editor.element.selectionEnd =
vditor.editor.element.selectionStart + original.length;
insertText(vditor.editor.element, responseJSON.data.url, "", true);
}
}
};
xhr.send(JSON.stringify({url: target.getAttribute("src")}));
}
return `![${target.getAttribute("alt")}](${target.getAttribute("src")})`;
},
});
turndownService.use(gfm);
const markdownStr = turndownService.turndown(textHTML);
if (onlyMultiCode) {
const tempElement = document.createElement("div");
tempElement.innerHTML = textHTML;
if (tempElement.querySelectorAll("pre").length > 1) {
onlyMultiCode = false;
} else if (markdownStr.substr(0, 3) !== "```" ||
markdownStr.substr(markdownStr.length - 3, 3) !== "```") {
onlyMultiCode = false;
}
private async setOriginal(vditor: IVditor) {
if (!vditor.originalInnerHTML.trim()) {
return;
}
if (onlyMultiCode) {
insertText(vditor.editor.element,
"```\n" + textPlain + "\n```",
"", true);
} else {
insertText(vditor.editor.element, markdownStr, "", true);
}
const mdValue = await html2md(vditor, vditor.originalInnerHTML);
insertText(vditor.editor.element, mdValue, "", true);
}

@@ -181,5 +121,3 @@

let TurndownService: ITurndown;
const html2md = this.html2md;
this.element.addEventListener("paste", (event: Event) => {
this.element.addEventListener("paste", async (event: Event) => {
event.stopPropagation();

@@ -191,13 +129,4 @@ event.preventDefault();

const textPlain = clipboardEvent.clipboardData.getData("text/plain");
if (!TurndownService) {
import(/* webpackChunkName: "vditor" */ "turndown").then((turndown) => {
TurndownService = turndown.default;
html2md(TurndownService, vditor, textHTML, textPlain);
}).catch((err) => {
console.error("Failed to load turndown", err);
});
return;
}
html2md(TurndownService, vditor, textHTML, textPlain);
const mdValue = await html2md(vditor, textHTML, textPlain);
insertText(vditor.editor.element, mdValue, "", true);
} else if (clipboardEvent.clipboardData.getData("text/plain").replace(/(^\s*)|(\s*)$/g, "") !== "" &&

@@ -220,2 +149,83 @@ clipboardEvent.clipboardData.files.length === 0) {

const html2md = async (vditor: IVditor, textHTML: string, textPlain?: string) => {
const { default: TurndownService } = await import(/* webpackChunkName: "vditor" */ "turndown");
let onlyMultiCode = false;
// no escape
TurndownService.prototype.escape = (name: string) => {
return name;
};
const turndownService = new TurndownService();
turndownService.addRule("strikethrough", {
filter: ["pre", "code"],
replacement: (content: string, node: HTMLElement) => {
if (node.parentElement.tagName === "PRE") {
return content;
}
if (content.split("\n").length > 1) {
onlyMultiCode = true;
return "```\n" + content + "\n```";
}
return "`" + content + "`";
},
});
turndownService.addRule("strikethrough", {
filter: ["img"],
replacement: (content: string, target: HTMLElement) => {
if (!target.getAttribute("src")) {
return "";
}
// 直接使用 API 或 setOriginal 时不需要对图片进行服务器上传,直接转换。
// 目前使用 textPlain 判断是否来自 API 或 setOriginal
if (vditor.options.upload.linkToImgUrl && textPlain) {
const xhr = new XMLHttpRequest();
xhr.open("POST", vditor.options.upload.linkToImgUrl);
xhr.onreadystatechange = () => {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
const responseJSON = JSON.parse(xhr.responseText);
if (responseJSON.code !== 0) {
alert(responseJSON.msg);
return;
}
const original = target.getAttribute("src");
vditor.editor.element.selectionStart =
vditor.editor.element.value.split(original)[0].length;
vditor.editor.element.selectionEnd =
vditor.editor.element.selectionStart + original.length;
insertText(vditor.editor.element, responseJSON.data.url, "", true);
}
}
};
xhr.send(JSON.stringify({url: target.getAttribute("src")}));
}
return `![${target.getAttribute("alt")}](${target.getAttribute("src")})`;
},
});
turndownService.use(gfm);
const markdownStr = turndownService.turndown(textHTML);
if (onlyMultiCode) {
const tempElement = document.createElement("div");
tempElement.innerHTML = textHTML;
if (tempElement.querySelectorAll("pre").length > 1) {
onlyMultiCode = false;
} else if (markdownStr.substr(0, 3) !== "```" ||
markdownStr.substr(markdownStr.length - 3, 3) !== "```") {
onlyMultiCode = false;
}
}
if (onlyMultiCode) {
return "```\n" + (textPlain || textHTML) + "\n```";
} else {
return markdownStr;
}
};
const insertText = (textarea: HTMLTextAreaElement, prefix: string, suffix: string, replace?: boolean) => {

@@ -297,2 +307,2 @@ if (typeof textarea.selectionStart === "number" && typeof textarea.selectionEnd === "number") {

export {Editor, insertText};
export {Editor, insertText, html2md};

@@ -254,2 +254,3 @@ /**

"dog2": "🐕",
"doge": `${imgStaticPath}/doge.png`,
"dollar": "💵",

@@ -256,0 +257,0 @@ "dolls": "🎎",

@@ -7,2 +7,3 @@ export const i18n: II18n = {

"emoji": "Emoji",
"fileTypeError": "file type is error",
"fullscreen": "Fullscreen",

@@ -17,2 +18,3 @@ "headings": "Headings",

"list": "List",
"nameEmpty": "Name is empty",
"ordered-list": "Order List",

@@ -36,2 +38,3 @@ "over": "over",

"emoji": "表情",
"fileTypeError": "文件类型不允许上传",
"fullscreen": "全屏",

@@ -46,2 +49,3 @@ "headings": "标题",

"list": "无序列表",
"nameEmpty": "文件名不能为空",
"ordered-list": "有序列表",

@@ -48,0 +52,0 @@ "over": "超过",

@@ -36,2 +36,3 @@ export class Preview {

xhr.open("POST", vditor.options.preview.url);
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhr.onreadystatechange = () => {

@@ -38,0 +39,0 @@ if (xhr.readyState === XMLHttpRequest.DONE) {

@@ -8,4 +8,7 @@ import uploadSVG from "../../assets/icons/upload.svg";

super(vditor, menuItem);
this.element.children[0].innerHTML = "<label>" + (menuItem.icon || uploadSVG) +
'<input multiple="multiple" type="file"></label>';
let inputHTML = '<input multiple="multiple" type="file"></label>';
if (vditor.options.upload.accept) {
inputHTML = `<input multiple="multiple" type="file" accept="${vditor.options.upload.accept}"></label>`;
}
this.element.children[0].innerHTML = `<label>${(menuItem.icon || uploadSVG)}${inputHTML}</label>`;
this._bindEvent(vditor);

@@ -12,0 +15,0 @@ }

@@ -21,2 +21,3 @@ declare module "*.svg" {

};
new(): {

@@ -60,2 +61,3 @@ addRule(name: string, options: {}): void

filename?: (name: string) => string;
accept?: string;
}

@@ -103,2 +105,3 @@

placeholder?: string;
editorName?: string;
lang?: (keyof II18nLang);

@@ -125,2 +128,3 @@ toolbar?: Array<string | IMenuItem>;

options: IOptions;
originalInnerHTML: string;
toolbar?: {

@@ -127,0 +131,0 @@ elements?: { [key: string]: HTMLElement },

export class Ui {
constructor(vditor: IVditor) {
const vditorElement = document.getElementById(vditor.id);
vditorElement.innerHTML = "";
vditorElement.className = "vditor" + (vditorElement.className ? " " + vditorElement.className : "");

@@ -5,0 +6,0 @@ if (typeof vditor.options.height === "number") {

@@ -12,3 +12,3 @@ import {insertText} from "../editor/index";

this.element.className = "vditor-upload";
this.element.innerHTML = '<div class="vditor-upload__progress"></div><div class="vditor-upload__close">x</div>';
this.element.innerHTML = '<div class="vditor-upload__progress"></div><div class="vditor-upload__close">X</div>';

@@ -22,6 +22,13 @@ this.element.children[1].addEventListener("click", function() {

const genUploadingLabel = (vditor: IVditor, files: DataTransferItemList | FileList | File[]): string => {
const validateFile = (vditor: IVditor, files: DataTransferItemList | FileList | File[]): File[] => {
vditor.upload.element.className = "vditor-upload";
const uploadFileList = [];
let errorTip = "";
let uploadingStr = "";
const lang: (keyof II18nLang) = vditor.options.lang;
for (let iMax = files.length, i = 0; i < iMax; i++) {
let file = files[i];
let validate = true;
if (file instanceof DataTransferItem) {

@@ -31,18 +38,53 @@ file = file.getAsFile();

const tag = file.type.indexOf("image") === -1 ? "" : "!";
if (!file.name) {
return "";
errorTip += `<li>${i18n[lang].nameEmpty}</li>`;
validate = false;
}
const lastIndex = file.name.lastIndexOf(".");
const filename = vditor.options.upload.filename(file.name.substr(0, lastIndex)) + file.name.substr(lastIndex);
const lang: (keyof II18nLang) = vditor.options.lang;
if (file.size > vditor.options.upload.max) {
vditor.upload.element.className = "vditor-upload vditor-upload--tip";
vditor.upload.element.children[0].innerHTML =
`${file.name} ${i18n[lang].over} ${vditor.options.upload.max / 1024 / 1024}M`;
} else {
uploadingStr += `${tag}[${filename}](${i18n[lang].uploading})\n`;
errorTip += `<li>${file.name} ${i18n[lang].over} ${vditor.options.upload.max / 1024 / 1024}M</li>`;
validate = false;
}
const lastIndex = file.name.lastIndexOf(".");
const fileExt = file.name.substr(lastIndex);
const filename = vditor.options.upload.filename(file.name.substr(0, lastIndex)) + fileExt;
if (vditor.options.upload.accept) {
let isAccept = false;
vditor.options.upload.accept.split(",").forEach((item) => {
const type = item.trim();
if (type.indexOf(".") === 0) {
if (fileExt === type) {
isAccept = true;
}
} else {
if (file.type.split("/")[0] === type.split("/")[0]) {
isAccept = true;
}
}
});
if (!isAccept) {
errorTip += `<li>${file.name} ${i18n[lang].fileTypeError}</li>`;
validate = false;
}
}
if (validate) {
uploadFileList.push(file);
uploadingStr += `${file.type.indexOf("image") === -1 ? "" : "!"}[${filename}](${i18n[lang].uploading})\n`;
}
}
return uploadingStr;
if (errorTip !== "") {
vditor.upload.element.className = "vditor-upload vditor-upload--tip";
vditor.upload.element.children[0].innerHTML = `<ul>${errorTip}</ul>`;
}
if (uploadingStr !== "") {
insertText(vditor.editor.element, uploadingStr, "");
}
return uploadFileList;
};

@@ -52,68 +94,57 @@

(editorElement: HTMLTextAreaElement, responseText: string, options: IOptions, uploadElement: HTMLElement) => {
editorElement.focus();
const response = JSON.parse(responseText);
editorElement.focus();
const response = JSON.parse(responseText);
if (response.code === 1) {
uploadElement.className = "vditor-upload vditor-upload--tip";
uploadElement.children[0].innerHTML = response.msg;
}
if (response.code === 1) {
uploadElement.className = "vditor-upload vditor-upload--tip";
uploadElement.children[0].innerHTML = response.msg;
}
response.data.errFiles.forEach((data: string) => {
const lastIndex = data.lastIndexOf(".");
const filename = options.upload.filename(data.substr(0, lastIndex)) + data.substr(lastIndex);
const original = `[${filename}](${i18n[options.lang].uploading})`;
editorElement.selectionStart = editorElement.value.split(original)[0].length;
editorElement.selectionEnd = editorElement.selectionStart + original.length;
insertText(editorElement, "", "", true);
});
response.data.errFiles.forEach((data: string) => {
const lastIndex = data.lastIndexOf(".");
const filename = options.upload.filename(data.substr(0, lastIndex)) + data.substr(lastIndex);
const original = `[${filename}](${i18n[options.lang].uploading})`;
editorElement.selectionStart = editorElement.value.split(original)[0].length;
editorElement.selectionEnd = editorElement.selectionStart + original.length;
insertText(editorElement, "", "", true);
});
Object.keys(response.data.succMap).forEach((key) => {
const path = response.data.succMap[key];
if (path.indexOf(".wav") === path.length - 4) {
insertText(editorElement, `<audio controls="controls" src="${path}"></audio>\n`, "");
return;
}
const lastIndex = key.lastIndexOf(".");
const filename = options.upload.filename(key.substr(0, lastIndex)) + key.substr(lastIndex);
const original = `[${filename}](${i18n[options.lang].uploading})`;
editorElement.selectionStart = editorElement.value.split(original)[0].length;
editorElement.selectionEnd = editorElement.selectionStart + original.length;
insertText(editorElement, `[${filename}](${path})`, "", true);
});
};
Object.keys(response.data.succMap).forEach((key) => {
const path = response.data.succMap[key];
if (path.indexOf(".wav") === path.length - 4) {
insertText(editorElement, `<audio controls="controls" src="${path}"></audio>\n`, "");
return;
}
const lastIndex = key.lastIndexOf(".");
const filename = options.upload.filename(key.substr(0, lastIndex)) + key.substr(lastIndex);
const original = `[${filename}](${i18n[options.lang].uploading})`;
editorElement.selectionStart = editorElement.value.split(original)[0].length;
editorElement.selectionEnd = editorElement.selectionStart + original.length;
insertText(editorElement, `[${filename}](${path})`, "", true);
});
};
const uploadFiles = (vditor: IVditor, files: FileList | DataTransferItemList | File[], element?: HTMLInputElement) => {
const formData = new FormData();
const uploadFileList = [];
for (let i = 0, iMax = files.length; i < iMax; i++) {
let file = files[i];
if (file instanceof DataTransferItem) {
file = file.getAsFile();
}
if (file.size <= vditor.options.upload.max) {
formData.append("file[]", file);
uploadFileList.push(file);
}
}
vditor.upload.element.className = "vditor-upload";
vditor.upload.element.children[0].innerHTML = "";
insertText(vditor.editor.element, genUploadingLabel(vditor, files), "");
if (uploadFileList.length === 0) {
if (!vditor.options.upload.url || !vditor.upload) {
if (element) {
element.value = "";
}
alert("please config: options.upload.url");
return;
}
if (!vditor.options.upload.url || !vditor.upload) {
const uploadFileList = validateFile(vditor, files);
if (uploadFileList.length === 0) {
if (element) {
element.value = "";
}
alert("please config: options.upload.url");
return;
}
const formData = new FormData();
for (let i = 0, iMax = uploadFileList.length; i < iMax; i++) {
formData.append("file[]", uploadFileList[i]);
}
const xhr = new XMLHttpRequest();

@@ -120,0 +151,0 @@ xhr.open("POST", vditor.options.upload.url);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc